This is a read-only copy of the MariaDB Knowledgebase generated on 2024-12-22. For the latest, interactive version please visit https://mariadb.com/kb/.

JSON_TYPE

Syntax

JSON_TYPE(json_val)

Description

Returns the type of a JSON value (as a string), or NULL if the argument is null.

An error will occur if the argument is an invalid JSON value.

The following is a complete list of the possible return types:

Return typeValueExample
ARRAYJSON array[1, 2, {"key": "value"}]
OBJECTJSON object{"key":"value"}
BOOLEANJSON true/false literalstrue, false
DOUBLEA number with at least one floating point decimal.1.2
INTEGERA number without a floating point decimal.1
NULLJSON null literal (this is returned as a string, not to be confused with the SQL NULL value!)null
STRINGJSON String"a sample string"

Examples

SELECT JSON_TYPE('{"A": 1, "B": 2, "C": 3}');
+---------------------------------------+
| JSON_TYPE('{"A": 1, "B": 2, "C": 3}') |
+---------------------------------------+
| OBJECT                                |
+---------------------------------------+
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.