Use JSON.parse (param) to achieve
Example:
var param = { "name": "Joe Smith" , "text" : { "Age": "18 is" , "Sex": "MALE" } } var obj = the JSON.parse (param); // a character JSON string into JSON object
Then, this can be read: console.log (obj.text); == >> {age: "18", sex: "male"}
Difference JSON.parse () and JSON.stringify () of
1.JSON.parse ( "to be converted arrays").
2.JSON.stringify ( "to be converted arrays").
3. Use a difference.
①.JSON.stringify string is parsed from an object.
②.JSON.parse json is parsed from a string (key-value pairs).
4. If the parameter does not correspond to the time of use, it can not be properly converted.
A .JSON.parse () {string parsed from a target json]
example:
1.// definition of a string, var data = '{ "name": "goatling"}'.
2.// analysis target, JSON.parse (data).
3. Results are:
name:"goatling"
Two .JSON.stringify () [parse the object from a character string]
1.var data={name:'goatling'}
2.JSON.stringify(data)
3. Results are:
'{"name":"goatling"}'