Product Solutions Support
Try MemSQL

JSON_GET_TYPE

Returns the Javascript type of the given JSON object.

JSON_GET_TYPE(json)

Arguments

Return Type

The type is returned as one of the following strings:

Examples

mysql> select json_get_type('true');
+-----------------------+
| json_get_type('true') |
+-----------------------+
| boolean               |
+-----------------------+

mysql> select json_get_type('12345');
+------------------------+
| json_get_type('12345') |
+------------------------+
| double                 |
+------------------------+

mysql> select json_get_type('"ohai"');
+-------------------------+
| json_get_type('"ohai"') |
+-------------------------+
| string                  |
+-------------------------+

mysql> select json_get_type('[1,2,3]');
+--------------------------+
| json_get_type('[1,2,3]') |
+--------------------------+
| array                    |
+--------------------------+

mysql> select json_get_type('{"a":1, "b":2}');
+---------------------------------+
| json_get_type('{"a":1, "b":2}') |
+---------------------------------+
| object                          |
+---------------------------------+

mysql> select json_get_type('null');
+-----------------------+
| json_get_type('null') |
+-----------------------+
| null                  |
+-----------------------+
Info

A JSON or Javascript null value is distinct from SQL NULL.

Was this article useful?