You are reading a single comment by @MaBe and its replies. Click here to read the full conversation.
  • 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').repl­ace(/\\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?

About

Avatar for MaBe @MaBe started