Returns the JSON type of a JSON value as a string.
Syntax
json_type(<json>)Parameters
| Parameter | Required | Description |
|---|---|---|
json | Yes | The JSON expression to evaluate. |
Return value
Returns a STRING value. The possible values correspond to the six types defined in the JSON specification:
| Return value | Description |
|---|---|
string | The JSON value is a string. |
number | The JSON value is a number. |
boolean | The JSON value is true or false. |
null | The JSON value is null. |
object | The JSON value is an object (key-value pairs enclosed in {}). |
array | The JSON value is an array (values enclosed in []). |
Examples
Return array for a JSON array:
SELECT json_type(json '[{"a":1}, 23]');+-------+
| _c0 |
+-------+
| array |
+-------+Return number for a JSON number:
SELECT json_type(json '123');+--------+
| _c0 |
+--------+
| number |
+--------+Return string for a JSON string:
SELECT json_type(json '"123"');+--------+
| _c0 |
+--------+
| string |
+--------+Related functions
JSON_TYPE is a complex type function. For more information about functions for processing ARRAY, MAP, STRUCT, and JSON data types, see Complex type functions.