Converts strings into data of the JSON type. If the strings that are converted are not in the JSON format, an error is reported.
Syntax
json json_parse(<string>)
Parameters
string: required. This parameter specifies the string that you want to process.
Return value
The return value is of the JSON type.
Examples
Example 1: Convert a string into data of the JSON type.
select json_parse('{"a":1, "b":2}');
The following result is returned:
+-----+ | _c0 | +-----+ | {"a":1,"b":2} | +-----+
Example 2: Convert a string into data of the JSON type.
select json_parse('"abc"');
The following result is returned:
+-----+ | _c0 | +-----+ | "abc" | +-----+
Example 3: Convert an invalid string into data of the JSON type. An error is reported.
select json_parse('abc');
The following result is returned:
Invalid input syntax for type json, detail:Token "abc" is invalid.
Related functions
JSON_PARSE is a complex type function. For more information about the functions that are used to process data of complex data types, such as ARRAY, MAP, STRUCT, and JSON, see Complex type functions.