Differences between JSON_QUERY and JSON_VALUE

You are viewing an old version of this article. View the current version here.
MariaDB starting with 10.2.3

JSON functions were added in MariaDB 10.2.3.

The primary difference between the two functions is that JSON_QUERY returns a scalar, and JSON_VALUE returns an object or an array.

Take the following JSON document as an example

SET @json='{ "x": [0,1], "y": "[0,1]", "z": "Monty" }';

Note that data member "x" is an array, and data members "y" and "z" are strings.

SELECT JSON_QUERY(@json,'$'), JSON_VALUE(@json,'$');
+--------------------------------------------+-----------------------+
| JSON_QUERY(@json,'$')                      | JSON_VALUE(@json,'$') |
+--------------------------------------------+-----------------------+
| { "x": [0,1], "y": "[0,1]", "z": "Monty" } | NULL                  |
+--------------------------------------------+-----------------------+

Comments

Comments loading...
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.