JSON (JavaScript Object Notation) is a lightweight data interchange format. It is based on a subset of ECMAScript. JSON takes a completely language-independent text format, but also uses a similar idiom to the C language family (c, C + +, C #, Java, JavaScript, Perl, Python, and so on). These features make JSON an ideal data exchange language. Easy to read and write, but also easy to machine parse and generate (network transfer speed).
It's an official definition, I can't read it. I'm just interested in the origin of JSON.
Anyway, JSON syntax rules:
Data in key-value pairs
Data is separated by commas
Curly braces Save Object
Square brackets Save Array
The writing format for JSON data is: Name: Value (name:value).
Name/value pairs are written in front (in double quotes), and value pairs are written in the following (same
In double quotes), separated by a colon in the middle:
"FirstName": "John"
This is easy to understand and is equivalent to this JAVASCRIPT statement:
Firstname= "John"
Specific format:
1, the object is an unordered "' name/value ' Pair" collection.
(1) An object starts with "{" (opening parenthesis) and "}" (closing parenthesis) ends.
(2) Each "name" followed by a ":" (colon);
(3) "' Name/value ' pair" is separated by "," (comma).
2, an array is an ordered set of values (value).
(1) An array begins with "[" (the left square bracket), and "]" (the right square bracket) ends.
(2) Use "," (comma) to separate values.
What is the specific JSON, personally think is to set the object to look good, well
A little bit easier to understand, see the code:
Summing up, with JSON syntax can be a simple assignment of custom objects, through the form of key-value pairs, easy to understand, the code is short, but the rules are determined, not easy to expand. In the actual application, according to different needs to use it.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
JSON syntax-A simple definition of an object