JSON是一种基于文本的数据交换方式
JSONP是的一种“使用模式”,可用于解决主流浏览器的跨域数据访问的问题。
JSON实例:
// 描述一个人var person = { "Name": "Bob", "Age": 32, "Company": "IBM", "Engineer": true}// 获取这个人的信息var personAge = person.Age;// 描述几个人var members = [ { "Name": "Bob", "Age": 32, "Company": "IBM", "Engineer": true }, { "Name": "John", "Age": 20, "Company": "Oracle", "Engineer": false }, { "Name": "Henry", "Age": 45, "Company": "Microsoft", "Engineer": false }]// 读取其中John的公司名称var johnsCompany = members[1].Company;// 描述一次会议var conference = { "Conference": "Future Marketing", "Date": "2012-6-1", "Address": "Beijing", "Members": [ { "Name": "Bob", "Age": 32, "Company": "IBM", "Engineer": true }, { "Name": "John", "Age": 20, "Company": "Oracle", "Engineer": false }, { "Name": "Henry", "Age": 45, "Company": "Microsoft", "Engineer": false } ]}// 读取参会者Henry是否工程师var henryIsAnEngineer = conference.Members[2].Engineer;