First, what is JSON?
JSON is the abbreviation for JavaScript object Notation, in short, the representation of JS objects, is a lightweight data interchange format.
JSON is the syntax for storing and exchanging textual information, similar to XML, but smaller, faster, and easier to parse than XML.
Second, JSON syntax:
JSON syntax is a subset of the JavaScript object notation syntax.
1. Data in name/value pairs;
2. Data is separated by commas;
3. Keep the object in curly braces;
4. square brackets Save the array.
For example:
var
json = {
"ch"
:[{
"names"
:
"怡美家园"
,
"data"
:[2,2,1,1,1,1],
"times"
:[10,11,13,13,21,23]},
{
"names"
:
"怡美家园"
,
"data"
:[2,2,1,1,1,1],
"times"
:[10,11,13,13,21,23]}
]
};
The JavaScript program can use the built-in eval () function to generate native JavaScript objects with JSON data.
JSON string converted to JSON format:
var txt = ' {' Employees ': [' +
' {' firstName ': ' Bill ', ' lastName ': ' Gates '}, ' +
' {' firstName ': ' George ', ' lastName ': ' Bush '}, ' +
' {' firstName ': ' Thomas ', ' lastName ': ' Carter '}]} ';
obj = json.parse (txt);
On Json/jsonp