There is a global JSON object in the JSON library, including 22 methods: The serializer is parse () and the parser stringify ()
Here is a description of the use of these two methods:
1.parse () to parse a JSON string into an object or array
var jsontext = ' {' userName ': ' Zhangsan ', ' Password ': ' 123456 '} ';//Note: Each attribute name and value are enclosed in double quotation marks and single quotes are written outside, otherwise an exception will occur.
var Changejson = Json.parse (jsontext);
Console.log (Changejson);//result is an object, object {userName: "Zhangsan", Password: "123456"}
2.stringify () is used to parse an object or array into a text string that contains the serialized JSON
var arr = [' C ', ' B ', {test:' C '}];
var arrchange = json.stringify (arr);
Console.log (arrchange);//The result is a JSON-formatted string, ["A", "B", {"Test": "C"}]
JSON serializer/parser in JavaScript