JSON = JavaScript Object notation
What is JSON
The text format of the data interchange, simply stated, is that each JSON object is a value, either a value of a simple type or a value of a composite type, but only one value, not two or more values, which means that each JSON document can contain only one value.
The advantages of JSON
Writing is simple, at a glance, in line with JavaScript native syntax and can be handled directly by the interpretation engine without adding additional parsing code.
JSON data types and formatting rules
· The value of a composite type can only be an array or an object, not a function, a regular expression object, or a Date object.
· There are only four values for a simple type: string, numeric value (must be represented in decimal), Boolean, and Null (cannot use nan,infinity,-infinity,undefined).
· The string must be in double quotation marks, cannot use single quotation marks ["One", "two", "three"]
· The key name of the object must be enclosed in double quotation marks {"One": 1, "two": 2, "three": 3} {"Names": ["Zhang San", "John Doe"]}
· After the last member of an array or object, you cannot add a comma [{"Name": "Zhang San"},{"name": "John Doe"}]
Two methods of JSON ( json.stringify () and Json.parse () )
Json.stringify () is used to convert a value to a string. The string should be in JSON format and can be restored by the Json.parse () method.
JSON object for JavaScript