Json
What
- 通过键来引用值
- a lightweight data interchange format
- is language independent
- The JSON format is syntactically identical to the code for creating JavaScript objects. Because of this similarity, a JavaScript program can easily convert JSON data into native JavaScript objects.(JavaScript 语法支持, 语法糖)
Basic Data Type (5)
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, 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
orfalse
Array
- an ordered list of zero or more values, 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.
- Objects are intended to represent associative arrays, where each key is unique within an object.
- 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.
More
null
- an empty value, using the word
null
- an empty value, using the word
- Whitespace is allowed and ignored around or between syntactic elements (values and punctuation, but not within a string value). Four specific characters are considered whitespace for this purpose: space, horizontal tab, line feed, and carriage return. In particular, the byte order mark must not be generated by a conforming implementation (though it may be accepted when parsing JSON). JSON does not provide syntax for comments.
- Early versions of JSON (such as specified by RFC 4627) required that a valid JSON text must consist of only an object or an array type, which could contain other types within them. This restriction was dropped in RFC 7158, where a JSON text was remark: d as any serialized value.
Vs 字典
字典是对 Hash Table 这一数据结构的一种实现, 它使用其内置的哈希函数来规划键对应的内容的储存位置,从而获得 O(1) 的数据读取速度