JSON (JavaScriptObjectNotation) is a lightweight data exchange format, which is very suitable for server-to-JavaScript interaction. Compared with XML, XML is easier to read and write. It is a subset of JavaScript. JSON is in a language-independent text format.
JSON (JavaScript Object Notation) is a lightweight data exchange format, which is very suitable for server-to-JavaScript interaction. Compared with XML, XML is easier to read and write. It is a subset of JavaScript. JSON is in a language-independent text format and can be used in popular languages, such as C # Java C ++ VB. These features make JSON an ideal data exchange language.
I. Json construction structure
1. A collection of name/value pairs ). In different languages, it is understood as an object, record, struct, dictionary, and hash table ), keyed list or associative array ).
2. An ordered list of values ). In most languages, it is understood as an array ).
These are common data structures. In fact, most modern computer languages support them in some form. This makes it possible to exchange a data format between programming languages that are also based on these structures.
II. Specific JSon Representation
1. The object is an unordered set of 'Key/value' pairs. An object starts with "{" (left parenthesis) and ends with "}" (right Parenthesis. Each "name" is followed by a ":" (colon); "," (comma) is used to separate the "name/value" pairs.
2. An array is an ordered set of values. An array starts with "[" (left square brackets) and ends with "]" (right square brackets. Values are separated by commas.
3. The value can be a string, a number, true, false, null, an object, or an array enclosed in double quotation marks ). These structures can be nested.
4. A string is a collection of any number of Unicode characters enclosed by double quotation marks. It is escaped using a backslash.
A character (character) is a separate string (character string ). A string is very similar to a C or Java string.
5. The value (number) is also very similar to the value in C or Java. Remove unused octal and hexadecimal formats. Except for some encoding details.
In javascript
[Javascript] view plaincopyprint?