“JS JSON ESCOP” Code-Antworten

Flucht 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. 
Yawning Yak

JS JSON ESCOP

JSON.parse(JSON.stringify(jsonObject));
GutoTrosla

Ähnliche Antworten wie “JS JSON ESCOP”

Fragen ähnlich wie “JS JSON ESCOP”

Weitere verwandte Antworten zu “JS JSON ESCOP” auf JavaScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen