json 即JavaScript Object Notation
JSON 语法是 JavaScript 语法的子集。
JSON 对象在花括号中书写:
对象可以包含多个名称/值对:
var json={ "firstName":"John" , "lastName":"Doe" }
访问json对象值
var name=json.firstName+ josn.lastName;
JSON 数组
JSON 数组在方括号中书写:
数组可包含多个对象:
var employees = [
{ "firstName":"John" , "lastName":"Doe" },
{ "firstName":"Anna" , "lastName":"Smith" },
{ "firstName":"Peter" , "lastName": "Jones" }
];
{ "firstName":"John" , "lastName":"Doe" },
{ "firstName":"Anna" , "lastName":"Smith" },
{ "firstName":"Peter" , "lastName": "Jones" }
];
eg:访问数组的第一个值
var name=employees[0].firstName
其中name等于John