escape json in javascript
JSON.parse(JSON.stringify(jsonObject));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.
Also in JavaScript:
- how to stop bubbling in javascript
- reactjs context
- Errors messages produced from JavaScript data validation.\
- what is nodes and hubs in selenium grid
- oneerror javascript image
- get caret position javascript
- next.js google script
- crypto node
- how to add a variable in js
- js convert order to char
- odd or even js
- js function
- adonis migration column char
- jquery get version
- javascript create object from key value pairs
- javascript find unique values in array of objects
- javascript querySelectorAll to array
- how to remove event listener in jquery
- javascript get last element of array pull
- how to access model data in jsp spring mvc
- js concat string
- How can I check whether a variable is defined in Node Js
- npm react-router-dom
- compare two dates using moment