var myJSONString = JSON.stringify(myJSON);var myEscapedJSONString = myJSONString.replace(/\\n/g, "\\n") .replace(/\\r/g, "\\r");