2.6. Semantics of null (null 的语义)
2.6. Semantics of null (null 的语义)
注意: JSON null 与其他 JSON 值同等对待, 即不表示 "undefined" 或 "missing (缺失)".
2.6.1. Examples (示例)
JSON:
{"a": null, "b": [null], "c": [{}], "null": 1}
Queries:
| Query | Result | Result | Comment |
|---|---|---|---|
| Paths | |||
| $.a | null | $['a'] | Object 值 |
| $.a[0] | null 用作 array | ||
| $.a.d | null 用作 object | ||
| $.b[0] | null | $['b'][0] | Array 值 |
| $.b[*] | null | $['b'][0] | Array 值 |
| $.b[?@] | null | $['b'][0] | 存在性 |
| $.b[?@==null] | null | $['b'][0] | 比较 |
| $.c[[email protected]==null] | 与 "缺失" | ||
| 值比较 | |||
| $.null | 1 | $['null'] | 并非 JSON null, |
| 仅为成员名字符串 |
表 17: 涉及 (或不涉及) null 的示例