Operator ->>
Get value of a JSON field as text.
It never looks into nested JSON documents. Special characters like /
in field names are escaped and not interpreted as JSON path separators.
Syntax
Parameters
Parameter | Description | Supported input types |
---|---|---|
<json> | The JSON document. | TEXT |
<field_name> | Name of the JSON field for which the value should be extracted. | TEXT |
Return Type
TEXT
- If any input values are
NULL
, the function will returnNULL
. - If the field name is not found in the JSON document, the function returns
NULL
.
Examples
The followingCREATE TABLE
and INSERT
statements set up the examples.
?column? (TEXT) |
---|
‘123’ |
?column? (TEXT) |
---|
‘3’ |
~
and /
in the field name when using the ->>
operator.
Example
?column? (TEXT) |
---|
'{\n "dyid": 987,\n "keywords" : ["insanely","fast","analytics"]\n }\n' |
value
as a TEXT
value.
Example
?column? (TEXT) |
---|
‘987’ |
->>
operator retrieves the nested JSON document in text form. Applying the second ->>
operator on the nested JSON document returns the value associated with the JSON field dyid
. The operator returns this value as a string.
Example
?column? (TEXT) |
---|
NULL |
value/dyid
. The ->>
operator never looks into nested JSON documents.