Updated on 2025-09-09 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 implement compatibility with MySQL, you need to enable the escape character function (configure enable_escape_string for the GUC parameter m_format_behavior_compat_options). However, the behavior is still different from that of MySQL in the \0 and \uxxxx scenarios.

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()

-