Returns the data type of a JSON value.
Syntax
string|number|boolean|null|object|array json_type(<json>)
Parameters
json: required. The JSON expression that you want to process.
Return value
A value of the STRING type is returned.
Examples
Example 1: Return the ARRAY type for a JSON value.
select json_type(json '[{"a":1}, 23]');
The following result is returned:
+-----+ | _c0 | +-----+ | array | +-----+
Example 2: Return a numeric data type for a JSON value.
select json_type(json '123');
The following result is returned:
+-----+ | _c0 | +-----+ | number | +-----+
Example 3: Return the STRING type for a JSON value.
select json_type(json '"123"');
The following result is returned:
+-----+ | _c0 | +-----+ | string | +-----+
Related functions
JSON_TYPE is a complex type function. For more information about functions related to the processing of data of complex data types, such as ARRAY, MAP, STRUCT, and JSON, see Complex type functions.