JSON_PARSE_NOTNULL_ERROR_TO_INVALID
Descriptionβ
This function is used to parse a JSON string. If the JSON string is malformed or a parsing error occurs, the function will return an invalid JSON object (usually {}
). The main purpose of this function is to ensure that when a JSON format error occurs, a safe default value is returned, preventing query failures due to parsing errors.
Aliasesβ
- JSONB_PARSE_NOTNULL_ERROR_TO_INVALID
Syntaxβ
JSON_PARSE_NOTNULL_ERROR_TO_INVALID( <str> )
Required Parametersβ
parameters | described |
---|---|
<str> | The JSON string to be parsed. This parameter should be a valid string containing JSON-formatted data. If the JSON format is invalid, the function will return an invalid JSON object. |
Return Valueβ
Returns an invalid JSON object (usually {}
).
Examplesβ
SELECT JSON_PARSE_NOTNULL_ERROR_TO_INVALID('{"name": "Alice", "age": 30}') AS parsed_json;
+---------------------------+
| parsed_json |
+---------------------------+
| {"name":"Alice","age":30} |
+---------------------------+