Aa= ' {"id": 0, "appId": "App***********id", "Appsecret": "Appsexxxxxxxxxrcret", "addbalance": 111, "UpdateTime": 0} '; varb = json.parse (aa); Converts a JSON string of type string to a JSON objectvarC= $.parsejson (aa); //Converts a JSON string of type string to a JSON object
alert (b.appid);//App***********id
alert (C.APPID); //Appsexxxxxxxxxrcret
var d=Json.stringigy (b)//Convert JSON object to JSON string}})
d={"id": 0, "appId": "App***********id", "Appsecret": "Appsexxxxxxxxxrcret", "addbalance": 111, "UpdateTime": 0}
alert (d);
JSON string Goto Object
var obj = eval (' (' + str + ') ');
var obj = Str.parsejson (); Convert from JSON string to JSON object
var obj = json.parse (str); Convert from JSON string to JSON object
Special Note: If obj is originally a JSON object, then using the eval () function to convert (even if multiple conversions) is a JSON object, but there is a problem with the Parsejson () function (throwing a syntax exception)
object to JSON string
var last=obj.tojsonstring (); Convert a JSON object to a JSON character
var last=json.stringify (obj); Convert a JSON object to a JSON character
In the above several methods, in addition to the eval () function is JS own, the other several methods are from the Json.js package. The new version of JSON modifies the API to inject json.stringify () and Json.parse () two methods into the Javascript built-in object, which becomes the object.tojsonstring (), and the latter becomes the Strin G.parsejson (). If you are prompted not to find the tojsonstring () and Parsejson () methods, your JSON package version is too low
JS parsing json