Updated on 2024-11-11 GMT+08:00

JSON Functions

Table 1 JSON functions

No.

MySQL

GaussDB

Difference

1

JSON_APPEND()

Supported.

-

2

JSON_ARRAY()

Supported.

-

3

JSON_ARRAY_APPEND()

Supported.

-

4

JSON_ARRAY_INSERT()

Supported.

-

5

JSON_CONTAINS()

Supported.

-

6

JSON_CONTAINS_PATH()

Supported.

-

7

JSON_DEPTH()

Supported.

-

8

JSON_EXTRACT()

Supported.

-

9

JSON_INSERT()

Supported.

-

10

JSON_KEYS()

Supported.

-

11

JSON_LENGTH()

Supported.

-

12

JSON_MERGE()

Supported.

-

13

JSON_MERGE_PATCH()

Supported.

-

14

JSON_MERGE_PRESERVE()

Supported.

-

15

JSON_OBJECT()

Supported.

-

16

JSON_QUOTE()

Supported.

-

17

JSON_REMOVE()

Supported.

-

18

JSON_REPLACE()

Supported.

-

19

JSON_SEARCH()

Supported.

-

20

JSON_SET()

Supported.

-

21

JSON_TYPE()

Supported.

-

22

JSON_UNQUOTE()

Supported, with differences.

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

23

JSON_VALID()

Supported.

-

JSON function differences: If JSON functions and other functions using characters as input parameters contain escape characters, the functions are different from those in MySQL by default. In this case, you need to set the GUC parameter SET m_format_behavior_compat_options to 'enable_escape_string'. Only scenarios involving escape characters are compatible with those in MySQL, but among them, scenarios involving \f, \Z, \0, and \uxxxx are different from MySQL.