Understanding JSON

The JSON : the JavaScript Object Notation (JavaScript Object Notation) is a lightweight data-interchange format.

json using entirely independent of the language of the text format, but also used language similar to C family habits (including C, JavaJavaScript, etc.). These properties make JSON an ideal data-interchange language. Easy to read and write, but also easy to generate and parse the machine (generally used to improve network transmission rate).

json is the syntax for storing and exchanging text messages.

 

Similarly XML

json plain text

json having a "self-descriptive" "human-readable"

json has a hierarchical structure (in the presence of values)

json can be parsed javaScript

json data may be transmitted using ajax

The difference compared to the XML :

No end tag, shorter
speed read faster

Possible to use the built-in javaScript eval () methods to parse

Using arrays

Do not use a reserved word

JSON syntax rules

json syntax is a subset of JavaScript syntax object representation of law

Data of the data separated by a comma in the name / value

Save braces brackets of the store arrays

JSON value

json values ​​can be: number (integer or floating point)

String (in double quotes) a logical value (true or false)

Array (in square brackets) objects (in braces)

null

JSON object

JSON objects written in curly braces ({}) in which:

Object may comprise a plurality of name / value pairs: Students {Name: "Joe Smith", Age: 18, Class: "class"};

JSON array

Writing json array in brackets:

Array may comprise a plurality of objects: persop [// array of structures can be nested objects Json

{Id: 1, name: "Zhang Shan"}, {id: 2, name: "John Doe"}]

In the above example, the object "person" is an array of two objects comprising

JSON boolean value

json Boolean value can be either true or false

{"flag":true}

JSON null

json null value may be provided:

{"run":null}

How to use JSON in JS

json is a subset of the javaScript syntax, so you can easily read the js, write json

Guess you like

Origin www.cnblogs.com/WeiXing-CDD17630955776/p/12143292.html