edwardbeckett
7/22/2015 - 1:40 PM

removeNull

removeNull

	<script>
		function removeNull( obj ) {
			return obj.replace( /\\u0{1,5}/gi, '' );
		}

		var obj = {
			nul : "\0char",
			sucks : "\u0000bad",
			needs : "\0fix",
			real : "\u0000 soon\0",
			complex : [{
				nul : "\0char",
				sucks : "\u0000bad",
				needs : "\0fix",
				real : "\u0000 soon\0"
			}],
			objects : [{
				nul : "\0char",
				sucks : "\u0000bad",
				needs : "\0fix",
				real : "\u0000 soon\0"
			}]
		};

	console.log( removeNull( JSON.stringify( obj ) ) );
	</script>