This article mainly tells the following several contents:
1, JSON definition and JSON features
2. How to interpret JSON-formatted data in JavaScript
3. How to use JSON in Java code (say object to JSON object and interpret JSON string)
One, JSON
There is a more detailed description of JSON on the http://www.w3school.com.cn/json/index.asp, linked to the link. Here are just a few important points.
JSON is a JavaScript Object notation (JavaScript objects notation), a lightweight text data interchange format with hierarchies (values in values), data that can be transmitted using AJAX, independent of language, and self descriptive, Smaller and faster and easier to parse than XML. JSON format strings are converted to JavaScript objects without a parser, JSON uses JavaScript syntax, and the eval () function of JavaScript is used to generate JavaScript objects.
Here's a JSON-formatted data, very clear, no need to explain, grammar please read the official document.
Standard JSON Format data
{"FirstName": "John", "LastName": "Doe"}
Standard JSON format array data
{
"Employees": [
{"FirstName": "John", "LastName": "Doe"},
{"FirstName": "Anna", "LastName": "Smith"},
{"FirstName": "Peter", "LastName": "Jones"}
]
}
or directly assigned to a variable:
var employees = [
{"FirstName": "Bill", "LastName": "Gates"},
{"FirstName": "George", "LastName": "Bush"},
{"FirstName": "Thomas", "LastName": "Carter"}
];
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/Java/