jQuery.parseJSON('{"name":"John"}') converts string representation to object
but I want the reverse. Object is to be converted to JSON string
I got a link http://www.devcurry.com/2010/03/convert-javascript-object-to-json.html
but it need to have json2.js. Does jQuery have a native method to do this?
jQuery.parseJSON(‘{"name":"John"}’) converts string representation to object but I want the reverse. Object is to
Share
jQuery does only make some regexp checking before calling the native browser method
window.JSON.parse(). If that is not available, it useseval()or more exactlynew Function()to create a Javascript object.The opposite of
JSON.parse()isJSON.stringify()which serializes a Javascript object into a string. jQuery does not have functionality of its own for that, you have to use the browser built-in version orjson2.jsfrom http://www.json.orgJSON.stringify()is available in all major browsers, but to be compatible with older browsers you still need that fallback.