JSON The grammar rules are very simple, no matter what method summary is only a few, it refers to the C Some of the habits of the language family will not be unfamiliar to learn.
Review JSON Five-point syntax
1)- Arrays (array) are expressed in square brackets ("[]") .
2)- Objects (object) are represented by braces ("{}").
3)- name / value pair (name/value) with a colon (": " ) separated.
4)- The nameisplaced in double quotation marks, and the values (value) have a string, a value, a Boolean value, a null, objects, and arrays.
5)- separate the data in parallel with commas (",")
Object ( Object)
1. The object is enclosed incurly braces ("{}"), and the braces are a series of " name / value pairs " , take a look at the concept map.
2, two parallel data separated by a comma (","), note two points:
1)- Use the comma in English (","), do not use a comma in Chinese ("," )
2)- do not add a comma after the last " name / value pair "
Sample code
{"Name": "Lucy",// value must be in double quotation marks
"Age": 25
}
Array ( Array)
The array represents a series of ordered values, surrounded by square brackets ("[]") and separated by commas, see concept map.
For example, the following array is legal:
[1,2,[1,2],{"AA": 1}]
name / value pairs (name/value)
1, name ( name ) is a string that is enclosed in double quotation marks, cannot be in single quotes, and cannot have no quotation marks, as with javascript different.
2, there are only seven types of values: string ( string ), numeric ( number object array true , false , null undefined
3. The following rules are the strings (string):
1)- enclose in double quotation marks, not in single quotes, or without.
2)- double quotation marks (") and right slash ("\ ") cannot appear in the string alone.
3)- If you want to double quote or right slash, you need to use the " right slash + character " form, for example \ " and \ \, and so are the other escape characters.
4. Concept diagram of the string.
Example code:
{
"String": "One Two"//the middle of the string can not be double quotation marks, must be used, with the escape character "\"
}
5. Concept map of Numerical value
Sample code
{
"Number": -10.01// cannot be hexadecimal and octal
}
original link:http://www.maiziedu.com/wiki/json/format/
A detailed explanation of JSON grammar rules