Json definition
权威定义
其他资料
json基本特点
JSON is purely a string with a specified data format — it contains only properties, no methods.
JSON requires double quotes to be used around strings and property names.
- Single quotes are not valid other than surrounding the entire JSON string.
Even a single misplaced comma or colon can cause a JSON file to go wrong, and not work.
- You should be careful to validate any data you are attempting to use (although computer-generated JSON is less likely to include errors, as long as the generator program is working correctly). You can validate JSON using an application like JSONLint.
JSON can actually take the form of any data type that is valid for inclusion inside JSON , not just arrays or objects.
- So for example, a single string or number would be valid JSON.(这种情况下用处不大)
Unlike in JavaScript code in which object properties may be unquoted, in JSON only quoted strings may be used as properties.
Data types
JSON’s basic data types are:
Number : a signed decimal number that may contain a fractional part and may use exponential E notation, but cannot include non-numbers such as NaN. The format makes no distinction between integer and floating-point. JavaScript uses a double-precision floating-point format for all its numeric values (until later also supports BigInt[24]), but other languages implementing JSON may encode numbers differently.- String: a sequence of zero or more Unicode characters. Strings are delimited with double-quotation marks and support a backslash escaping syntax.
- Boolean: either of the values
true or false - Array: an ordered list of zero or more elements, each of which may be of any type. Arrays use square bracket notation with comma-separated elements.
- Object: a collection of name–value pairs where the names (also called keys) are strings. The current ECMA standard states: “The JSON syntax does not impose any restrictions on the strings used as names, does not require that name strings be unique, and does not assign any significance to the ordering of name/value pairs.”[25] Objects are delimited with curly brackets and use commas to separate each pair, while within each pair the colon ‘:’ character separates the key or name from its value.
null : an empty value, using the word null
|