Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

escape json in javascript

var myJSONString = JSON.stringify(myJSON);
var myEscapedJSONString = myJSONString.replace(/
/g, "
")
                                      .replace(/'/g, "'")
                                      .replace(/"/g, '"')
                                      .replace(/&/g, "&")
                                      .replace(/
/g, "
")
                                      .replace(/	/g, "	")
                                      .replace(//g, "")
                                      .replace(/f/g, "f");
// myEscapedJSONString is now ready to be POST'ed to the server. 
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #escape #json #javascript
ADD COMMENT
Topic
Name
1+2 =