Json:javascript Simple Object notation.
JSON is the object of JS, but it omits the tags in the XML, but instead uses the {} to complete the description of the object.
Defining objects
var person = { // by property Name: property value to indicate, different attributes passed, to interval age:25, function() { alert (this, age); } // the last property cannot be followed by a }person.say ();
Defining an Ordinary array
You can still create an array of objects through JSON, just as you would create an array of JS.
var array = [ {name:"Zs", Age:24}, {name:"ls", age:25}]; for (var i=0; i<array.length; i++) { alert (array[i].name);}
Defining an array of objects
Create a group of users with a property of name, age, friends
Person.java:name:string, Age:int, Friends:array
list<person> PS = new arraylist<person> ();
Ps.add (New person ("Leon", 22,["Ada", "Alice"]));
Ps.add (New person ("John", 33,["Ada", "Chris"]));
var persons = [ { "Leon", friends:["Ada", "Alice"] }, { "John", friends:[,"Ada", "Chris"] } for (var i=0; i<persons.length; i++) { +--+ + Persons[i].age + "-- > "+ persons[i].friends);}
The creation of JavaScript objects is defined using JSON format