JSON-JavaScript Object Notation is a lightweight data-interchange format.It is easy for humans to read and write.It is easy for machines to parse and generate.It is based on a subset of JavaScript Language.
JSON is a text format that is completely language independent but uses convention that is familiar to the programmars of the c-family language,including c, c++, java,perl,python ,javascript and many others.These properties make the JSON an ideal data interchange language.
JSON is built on two structures:
1. A collection of name/value pairs.
2. A ordered list value.( List,Vector, ArrayList)
These are universal data structures. Virtually all modern programming languages support them in one form or another. It makes sense that a data format that is interchangable with programming languages also be based on these structures.
var array = eval("[1,2,3]"); array[0]; // 1 array[1]; // 2 array[2]; // 3 function showJSON() { var user = { "username":"andy", "age":20, "info": { "tel": "123456", "cellphone": "98765"}, "address": [ {"city":"beijing","postcode":"222333"}, {"city":"newyork","postcode":"555666"} ] } alert(user.username); alert(user.age); alert(user.info.cellphone); alert(user.address[0].city); alert(user.address[0].postcode); }
will focus on the json for details