Thanks in advance.
JSON.parse() in JSON2 documentation
myData = JSON.parse(text); // from json string to js object var myJSONText = JSON.stringify(myObject, replacer); // js object to json string
If the JSON object is available, you can use :
var aString = JSON.stringify(anObject);
to transform an object into JSON string.
You can also convert a string into an object with
var obj = JSON.parse(aString)
To be sure that JSON is available, you can include this file https://github.com/douglascrockford/JSON-js
you should use Douglas Crockford's JSON2 library.
That way, you could:
var jsonString = JSON.stringify(obj);
var Obj = JSON.parse(jsonString);
If you use jQuery.getJSON you don't have to care about stringifying and parsing json, jquery does it for you.
©2020 All rights reserved.