Got some special chars in JSON that needed to be escapes.
var aJS = {txt : "012345\nabcde\näöüß"};
var s_aJS5 = E.toJS(aJS);
// "{txt:\"012345\\nabcde\\n\\xE4\\xF6\\xFC\\xDF\"}";
// but in some cases additional encoding is required
var s_aJS5_e = E.toJS(aJS).replace(/\\n/g,'\\\\n').replace(/\\x/g,'\\\\x');
// "{txt:\"012345\\\\nabcde\\\\n\\\\xE4\\\\xF6\\\\xFC\\\\xDF\"}";
Is there a Espruino function for this, or could this be another candidate for StringDecoders?
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Got some special chars in JSON that needed to be escapes.
Is there a Espruino function for this, or could this be another candidate for
StringDecoders
?