mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
add docs
This commit is contained in:
parent
6b5a102a5b
commit
eafac0f9a3
@ -471,3 +471,38 @@ Result:
|
||||
|
||||
- [output_format_json_quote_64bit_integers](../../operations/settings/settings.md#session_settings-output_format_json_quote_64bit_integers)
|
||||
- [output_format_json_quote_denormals](../../operations/settings/settings.md#settings-output_format_json_quote_denormals)
|
||||
|
||||
|
||||
## JSONArrayLength
|
||||
|
||||
Returns the number of elements in the outermost JSON array. The function returns NULL if input JSON string is invalid.
|
||||
|
||||
**Syntax**
|
||||
|
||||
``` sql
|
||||
JSONArrayLength(json)
|
||||
```
|
||||
|
||||
Alias: `JSON_ARRAY_LENGTH(json)`.
|
||||
|
||||
**Arguments**
|
||||
|
||||
- `json` — [String](../../sql-reference/data-types/string.md) with valid JSON.
|
||||
|
||||
**Returned value**
|
||||
|
||||
- If `json` is a valid JSON array string, returns the number of array elements, otherwise returns NULL.
|
||||
|
||||
Type: [Nullable(UInt64)](../../sql-reference/data-types/int-uint.md).
|
||||
|
||||
**Example**
|
||||
|
||||
``` sql
|
||||
SELECT
|
||||
JSONArrayLength(''),
|
||||
JSONArrayLength('[1,2,3]')
|
||||
|
||||
┌─JSONArrayLength('')─┬─JSONArrayLength('[1,2,3]')─┐
|
||||
│ ᴺᵁᴸᴸ │ 3 │
|
||||
└─────────────────────┴────────────────────────────┘
|
||||
```
|
||||
|
@ -1,13 +1,16 @@
|
||||
-- { echoOn }
|
||||
select json_array_length(null);
|
||||
select json_array_length('');
|
||||
select json_array_length('[]');
|
||||
select json_array_length('[1,2,3]');
|
||||
select json_array_length('[[1,2],[5,6,7]]');
|
||||
select json_array_length('[{"a":123},{"b":"hello"}]');
|
||||
select json_array_length('[1,2,3,[33,44],{"key":[2,3,4]}]');
|
||||
select json_array_length('{"key":"not a json array"}');
|
||||
select json_array_length('[1,2,3,4,5');
|
||||
select JSONArrayLength(null);
|
||||
select JSONArrayLength('');
|
||||
select JSONArrayLength('[]');
|
||||
select JSONArrayLength('[1,2,3]');
|
||||
select JSONArrayLength('[[1,2],[5,6,7]]');
|
||||
select JSONArrayLength('[{"a":123},{"b":"hello"}]');
|
||||
select JSONArrayLength('[1,2,3,[33,44],{"key":[2,3,4]}]');
|
||||
select JSONArrayLength('{"key":"not a json array"}');
|
||||
select JSONArrayLength('[1,2,3,4,5');
|
||||
|
||||
select json_array_length(2); -- { serverError ILLEGAL_TYPE_OF_ARGUMENT }
|
||||
select json_array_length(); -- { serverError NUMBER_OF_ARGUMENTS_DOESNT_MATCH }
|
||||
select JSON_ARRAY_LENGTH('[1,2,3,4,5');
|
||||
select JSON_ARRAY_LENGTH('[1,2,3,4,5]');
|
||||
|
||||
select JSONArrayLength(2); -- { serverError ILLEGAL_TYPE_OF_ARGUMENT }
|
||||
select JSONArrayLength(); -- { serverError NUMBER_OF_ARGUMENTS_DOESNT_MATCH }
|
||||
|
Loading…
Reference in New Issue
Block a user