JSON [ JavaScript Object Notation ]: JavaScript object notation.
It is a lightweight data exchange format.
JSON is more convenient as a data format than XML in many situations.
JSON data consists of objects, arrays, elements and other formats. Each format can contain legal JavaScript data types.
In JavaScript, you can directly convert a string into JSON format through the eval() method.
JSON data source format is as follows:
Example 1:
{
"tablename ":"Table name",
"rows":[{"Column 1":"Value 1"},{"Column 2":"Value 2"}....{"Column n":" Value n"}]
}
Example 2:
/* Code equivalent to JSON
var obj = new Object();
obj.createPerson = function(_name,_age){
this.name = _name ;
this.age = _age;
}
obj.getAge = function(){
return this.age;
}
*/
var person = { "Createperson": Function (_name, _age) {
this.name = _name;
this.age = _age;
},
"getage": function () {{
return this.age; (p);
Example 3: Use the eval() method to directly convert the string into JSON and obtain the value of the element.
Copy code
The code is as follows: