Answers for "js json escape"

0

escape json in javascript

var myJSONString = JSON.stringify(myJSON);
var myEscapedJSONString = myJSONString.replace(/\\n/g, "\\n")
                                      .replace(/\\'/g, "\\'")
                                      .replace(/\\"/g, '\\"')
                                      .replace(/\\&/g, "\\&")
                                      .replace(/\\r/g, "\\r")
                                      .replace(/\\t/g, "\\t")
                                      .replace(/\\b/g, "\\b")
                                      .replace(/\\f/g, "\\f");
// myEscapedJSONString is now ready to be POST'ed to the server.
Posted by: Guest on November-20-2020
1

js json escape

JSON.parse(JSON.stringify(jsonObject));
Posted by: Guest on October-25-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language