您可以使用 IS_NULL_VALUE 来查看密钥是否存在。如果键不存在,则结果将为 NULL。如果键存在,如果值为 JSON null,则结果将为 TRUE,如果存在非 null JSON 值,则结果将为 FALSE:
select parse_json('{hello: NULL, world: 123}') as V,
V:hello,
V:world,
IS_NULL_VALUE(v:hello),
IS_NULL_VALUE(v:world),
IS_NULL_VALUE(v:goodbye),
IFF(IS_NULL_VALUE(v:non_existing_key) is null, 'Key does not exist', 'Key exists'),
IFF(IS_NULL_VALUE(v:hello) is null, 'Key does not exist', 'Key exists'),
IFF(IS_NULL_VALUE(v:world) is null, 'Key does not exist', 'Key exists')
;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1506 次 |
| 最近记录: |