Converts a JSON string into a VARIANT value.
Limits
This function is supported only in Ververica Runtime (VVR) 11.1.0 or later.
Syntax
VARIANT PARSE_JSON(VARCHAR jsonStr [, BOOLEAN allowDuplicateKeys])Arguments
Argument | Data type | Description |
| VARCHAR | The JSON string to be parsed. Note If the input is NULL, the function returns NULL. |
| BOOLEAN | This optional argument specifies whether duplicate keys are allowed. Valid values:
|
Comparison of PARSE_JSON and TRY_PARSE_JSON
Function | Error handling mechanism | Return value for invalid JSON input | Suitable scenarios |
Explicitly raises errors. | Returns an error. | Strict input validation is required. | |
Tolerates errors. | Returns | Tolerance for invalid input is needed. |
Example
Test data in the
T1table:jsonString(VARCHAR)
{"k": "v1", "k2": 1}
Test statement:
SELECT PARSE_JSON(jsonString) AS v FROM T1;Results:
v
(VARIANT)
{"k": "v1", "k2": 1}