A detailed explanation of JSON grammar rules

Source: Internet
Author: User

  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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.