Function Name | Statement | Description |
json_array_contains(x,value) | Determines whether a JSON array contains a specified value. | |
json_array_get(x,index) | Obtains the element at a specified index in a JSON array. | |
json_array_length(x) | Calculates the number of elements in a JSON array. If x is not a JSON array, null is returned. | |
json_extract(x,json_path) | Extracts a set of JSON values (array or object) from a JSON object or array. | |
json_extract_scalar(x,json_path) | Extracts a set of scalar values (strings, integers, or Boolean values) from a JSON object or array. This function is similar to the json_extract function. | |
json_format(x) | Converts a JSON value into a string value. | |
json_parse(x) | Converts a string value into a JSON value. | |
json_size(x,json_path) | Calculates the number of elements in a JSON array or object. |
json_array_contains(x, value)
Parameter | Description |
x | The parameter value must be a JSON array. |
value | Value. |
* | SELECT json_array_contains('[1, 2, 3]', 2)
true
json_array_get(x, index)
Parameter | Description |
x | The parameter value must be a JSON array. |
index | JSON index, starting from 0. |
* | SELECT json_array_get('["a", [3, 9], "c"]', 1)
[3,9]
json_array_length(x)
Parameter | Description |
x | The parameter value must be a JSON array. |
apple.message:[{"traceName":"StoreMonitor"},{"topicName":"persistent://apache/pulsar/test-partition-17"},{"producerName":"pulsar-mini-338-36"},{"localAddr":"pulsar://pulsar-mini-broker-5.pulsar-mini-broker.pulsar.svc.cluster.local:6650"},{"sequenceId":826},{"storeTime":1635905306062},{"messageId":"19422-24519"},{"status":"SUCCESS"}]
* | SELECT json_array_length(apple.message)
8
json_extract(x, json_path)
Parameter | Description |
x | The parameter value must be a JSON object or array. |
json_path | Note: JSON syntax that requires traversing array elements is not supported, such as $.store.book[*].author, $..book[(@.length-1)], $..book[?(@.price<10)], and so on.When an element name contains special characters, use the [] syntax instead of the . syntax and enclose the element name in double quotation marks, for example, $.store["book name"]. |
apple.instant:{"epochSecond":1635905306,"nanoOfSecond":63001000}
* | SELECT json_extract(apple.instant, '$.epochSecond')
1635905306
json_extract_scalar(x, json_path)
Parameter | Description |
x | The parameter value must be a JSON array. |
json_path | Note: JSON syntax that requires traversing array elements is not supported, such as $.store.book[*].author, $..book[(@.length-1)], $..book[?(@.price<10)], and so on.When an element name contains special characters, use the [] syntax instead of the . syntax and enclose the element name in double quotation marks, for example, $.store["book name"]. |
apple.instant:{"epochSecond":1635905306,"nanoOfSecond":63001000}
* | SELECT sum(cast(json_extract_scalar(apple.instant,'$.epochSecond') AS bigint) )
1635905306
json_format(x)
Parameter | Description |
x | The parameter value must be of the JSON type. |
* | SELECT json_format(json_parse('[1, 2, 3]'))
[1, 2, 3]
json_parse(x)
Parameter | Description |
x | The parameter value must be a string. |
* | SELECT json_parse('[1, 2, 3]')
[1, 2, 3]
json_size(x, json_path)
Parameter | Description |
x | The parameter value must be a JSON object or array. |
json_path | Note: JSON syntax that requires traversing array elements is not supported, such as $.store.book[*].author, $..book[(@.length-1)], $..book[?(@.price<10)], and so on.When an element name contains special characters, use the [] syntax instead of the . syntax and enclose the element name in double quotation marks, for example, $.store["book name"]. |
* | SELECT json_size(json_parse('[1, 2, 3]'),'$')
3
피드백