Updated on 2025-04-14 GMT+08:00

JSON Functions

JSON function differences: If you add escape characters as input parameters to JSON functions and other functions that allow characters, the processing is different from that in MySQL by default. To be compatible with MySQL, set the GUC parameter standard_conforming_strings to off. In this case, the escape character processing is compatible with MySQL, except when the escape character \f, \Z, \0, or \uxxxx is used.

Table 1 JSON functions

Function

Differences Compared with MySQL

JSON_APPEND()

-

JSON_ARRAY()

-

JSON_ARRAY_APPEND()

-

JSON_ARRAY_INSERT()

-

JSON_CONTAINS()

-

JSON_CONTAINS_PATH()

-

JSON_DEPTH()

-

JSON_EXTRACT()

-

JSON_INSERT()

-

JSON_KEYS()

-

JSON_LENGTH()

-

JSON_MERGE()

-

JSON_MERGE_PATCH()

-

JSON_MERGE_PRESERVE()

-

JSON_OBJECT()

-

JSON_QUOTE()

-

JSON_REMOVE()

-

JSON_REPLACE()

-

JSON_SEARCH()

-

JSON_SET()

-

JSON_TYPE()

-

JSON_UNQUOTE()

The scenarios where escape characters \0 and \uxxxx are used are different from those in MySQL.

SELECT json_unquote('"\0"');

mysql> SELECT json_unquote('"\0"');
ERROR 3141 (22032): Invalid JSON text in argument 1 to function json_unquote: "Missing a closing quotation mark in string." at position 1.

m_db=# SELECT json_unquote('"\0"');
ERROR:  invalid byte sequence for encoding "UTF8": 0x00

JSON_VALID()

-