JSON javascript object notation 是一种轻量级的数据交换格式。 易于人阅读和编写。同时也易于机器解析和生成。JSON采用完全独立于语言的文本格式,但是也使用了类似于C语言家族的习惯(包括C, C++, C#, Java, JavaScript, Perl, Python等)。 这些特性使JSON成为理想的数据交换语言。
JSON建构于两种结构:
- 名称/值”对的集合(A collection of name/value pairs)。不同的语言中,它被理解为对象(object),纪录(record),结构(struct),字典(dictionary),哈希表(hash table),有键列表(keyed list),或者关联数组 (associative array)。
- 值的有序列表(An ordered list of values)。在大部分语言中,它被理解为数组(array)。
有序列表
元素表达方式为int boolean float string 等,object用{}包围, 而array用[]包围代表list of value
JSON vs relational model
行\列 | relational model | JSON |
---|---|---|
structure | table | nested sets, arrays |
schema | fixed in advanced | self-describing, flexible |
Queries | simple expressive language | for program read and write |
ordering | no order, if want, do query | it has arrays |
implementation | Native system | no sql system |
JSON属性
JSON的array 可以为空,object也可以为空,但是object必须是label-value pairs
JSON SCHEMA
JSON 模式是一种基于 JSON 格式定义 JSON 数据结构的规范。