mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 17:12:03 +00:00
Update json-functions.md
This commit is contained in:
parent
900a359362
commit
1b2186b8ad
@ -315,10 +315,10 @@ If the value does not exist, `0` will be returned.
|
||||
Examples:
|
||||
|
||||
``` sql
|
||||
SELECT JSON_EXISTS('$.hello', '{"hello":1}');
|
||||
SELECT JSON_EXISTS('$.hello.world', '{"hello":{"world":1}}');
|
||||
SELECT JSON_EXISTS('$.hello[*]', '{"hello":["world"]}');
|
||||
SELECT JSON_EXISTS('$.hello[0]', '{"hello":["world"]}');
|
||||
SELECT JSON_EXISTS('{"hello":1}', '$.hello');
|
||||
SELECT JSON_EXISTS('{"hello":{"world":1}}', '$.hello.world');
|
||||
SELECT JSON_EXISTS('{"hello":["world"]}', '$.hello[*]');
|
||||
SELECT JSON_EXISTS('{"hello":["world"]}', '$.hello[0]');
|
||||
```
|
||||
|
||||
!!! note "Note"
|
||||
@ -326,17 +326,17 @@ SELECT JSON_EXISTS('$.hello[0]', '{"hello":["world"]}');
|
||||
|
||||
## JSON_QUERY(json, path) {#json-query}
|
||||
|
||||
Parses a JSON and extract a value.
|
||||
Parses a JSON and extract a value as JSON array or JSON object.
|
||||
|
||||
If the value does not exist, an empty string will be returned.
|
||||
|
||||
Example:
|
||||
|
||||
``` sql
|
||||
SELECT JSON_QUERY('$.hello', '{"hello":"world"}');
|
||||
SELECT JSON_QUERY('$.array[*][0 to 2, 4]', '{"array":[[0, 1, 2, 3, 4, 5], [0, -1, -2, -3, -4, -5]]}');
|
||||
SELECT JSON_QUERY('$.hello', '{"hello":2}');
|
||||
SELECT toTypeName(JSON_QUERY('$.hello', '{"hello":2}'));
|
||||
SELECT JSON_QUERY('{"hello":"world"}', '$.hello');
|
||||
SELECT JSON_QUERY('{"array":[[0, 1, 2, 3, 4, 5], [0, -1, -2, -3, -4, -5]]}', '$.array[*][0 to 2, 4]');
|
||||
SELECT JSON_QUERY('{"hello":2}', '$.hello');
|
||||
SELECT toTypeName(JSON_QUERY('{"hello":2}', '$.hello'));
|
||||
```
|
||||
|
||||
Result:
|
||||
@ -352,17 +352,17 @@ String
|
||||
|
||||
## JSON_VALUE(json, path) {#json-value}
|
||||
|
||||
Parses a JSON and extract a value.
|
||||
Parses a JSON and extract a value as JSON scalar.
|
||||
|
||||
If the value does not exist, an empty string will be returned.
|
||||
|
||||
Example:
|
||||
|
||||
``` sql
|
||||
SELECT JSON_VALUE('$.hello', '{"hello":"world"}');
|
||||
SELECT JSON_VALUE('$.array[*][0 to 2, 4]', '{"array":[[0, 1, 2, 3, 4, 5], [0, -1, -2, -3, -4, -5]]}');
|
||||
SELECT JSON_VALUE('$.hello', '{"hello":2}');
|
||||
SELECT toTypeName(JSON_VALUE('$.hello', '{"hello":2}'));
|
||||
SELECT JSON_VALUE('{"hello":"world"}', '$.hello');
|
||||
SELECT JSON_VALUE('{"array":[[0, 1, 2, 3, 4, 5], [0, -1, -2, -3, -4, -5]]}', '$.array[*][0 to 2, 4]');
|
||||
SELECT JSON_VALUE('{"hello":2}', '$.hello');
|
||||
SELECT toTypeName(JSON_VALUE('{"hello":2}', '$.hello'));
|
||||
```
|
||||
|
||||
Result:
|
||||
|
Loading…
Reference in New Issue
Block a user