JSFiddle - React, Tailwind, and code Playground

by Liu David

JavaScript

var strTest = "1";

function justifyStringForJson(str) {
		var newStr = str.replace(/"/g, '\\"');
		var str2 = newStr.replace(/[\u200B-\u200D\uFEFF]/g, '');
		return str2;
	
	}

var out = justifyStringForJson(strTest);
alert('original len:'+strTest.length+'\nnew len:'+out.length);
alert('char code: '+strTest.charCodeAt(0));