Home  >  Article  >  Web Front-end  >  Detailed introduction to json objects in js_javascript skills

Detailed introduction to json objects in js_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:32:481203browse

1.JSON (JavaScript Object Notation) is a simple data format that is more lightweight than xml. JSON is a native JavaScript format, which means that no special API or toolkit is required to handle JSON data in JavaScript.
The rules of JSON are simple: an object is an unordered collection of "name:value" pairs. An object starts with "{" (left bracket) and ends with "}" (right bracket). Each "name" is followed by a ":" (colon); "name/value" pairs are separated by "," (comma).

The rules are as follows:

1) Mapping is represented by colon (":"). Name:value
2) Parallel data are separated by commas (","). Name 1: Value 1, Name 2: Value 2
3) The mapped collection (object) is represented by curly brackets ("{}"). {Name1:Value1,Name2:Value2}
4) The collection (array) of parallel data is represented by square brackets ("[]").
[
{name1:value,name2:value2},

{name1:value, name2:value2}

]
5) The types that element values ​​can have: string, number, object, array, true, false, null

Five writing methods in 2.json:

1) Traditional way of storing data and calling data

Copy code The code is as follows:



2) The first style:
Copy code The code is as follows:



3) Second style:
Copy code The code is as follows:



4) The third style:
Copy code The code is as follows:



5) The fourth style:
Copy code The code is as follows:



6) The fifth style:
Copy code The code is as follows:


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn