As with XML, JSON is also a data format based on plain Text. Since JSON is inherently prepared for JavaScript, the JSON data format is very simple and can be used to transmit a simple string,number,boolean, or to transfer an array, or a complex object.
The basic structure of JSON is to use "{}" to wrap an object that contains a key and value separated by a colon, a comma delimited between Key-value pairs, a string to be wrapped in double quotation marks (""), and the Object's key name is always a string, and the property value enables any json-supported data type, including string, Other object types, numbers, and Boolean types (true or false), a specified null value, and an array. The JSON array is wrapped by "[]", the type of the array element can be any JSON data type (including objects and arrays), and the array elements are separated by ",".
{"total": 3,"rows":[ { "userId": 1, "realname": "zhang mei", "headurl": "href= ' teacherdetail.html '", "img": "src= ' images/teacher.jpg '", "introduction": "warm and generous." " },{ "userId": 2, "realname": "zhang san", "headurl": "href= ' teacherdetail.html '", "img": "src= ' images/teacher.jpg '", "introduction": "warm and generous." " },{ "userId": 3, "realname": "reese", "headurl": "href= ' teacherdetail.html '", "img": "src= ' images/teacher.jpg '", "introduction": "warm and generous" }]}
The $.getjson () method function in jquery is primarily used to load json-encoded data from the server, which uses a get HTTP Request. Here's How to use It:
$.getjson (url,[data], [success (data, textstatus, jqxhr)])
The URL is a required parameter that represents the address of the JSON data;
Data is an optional parameter that is used to send parameters when data is requested;
Success is a parameter, which is a callback function that is used to process the requested Data.
Get JSON data for example:
$.getjson (' Test.json ', function (data) { for(var i = 0; i < data.rows.length; i++) { $ ( /c4> ' #test '). append (' <p> ' + data.rows[i].realname + ' </p> ');} );
Jsonobject and Jsonarray
The difference is that Jsonobject is a {} wrapped object,
The Jsonarray is an array of [] Packages.
The white point is an array, an object or a string.
JSONOBJEC has a key name, Jsonarray Not.
JSON, jsonarray, and Jsonobject