Updated on 2025-06-30 GMT+08:00

JSON Functions

JSON function differences:

  • If you add escape characters as input parameters to JSON functions and other functions that allow character inputs, 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 processing of escape characters is compatible with MySQL, but a warning is generated for non-standard character input. The escape characters \t and \u and escape digits are different from those in MySQL. The JSON_UNQUOTE () function is compatible with MySQL. Even if the GUC parameter is not set, no alarm is generated.
  • When processing an ultra-long number (the number contains more than 64 characters), the JSON function of GaussDB parses the number as a DOUBLE and uses scientific notation for counting. The input parameters of the non-JSON type are the same as those of MySQL. However, when input parameters of the JSON type are used, the JSON type is not completely compatible with MySQL. As a result, differences occur in this scenario. MySQL displays complete numbers. (When the number length exceeds 82, MySQL displays an incorrect result.) GaussDB still parses an ultra-long number into a double-precision value. Long numbers are stored using floating-point numbers. During calculation, precision loss occurs in both GaussDB and MySQL. Therefore, you are advised to use character strings to store long numbers.
    gaussdb=# SELECT json_insert('[1, 4, 99999999999999999999999999999999999999999999999999999999999999999999999999]','$[6]',json_insert('[1,4]','$[5]',99999999999999999999999999999999999999999999999999999999999999999999999999));
             json_insert          
    ------------------------------
     [1, 4, 1e+74, [1, 4, 1e+74]]
    (1 row)
Table 1 JSON functions

MySQL

GaussDB

Difference

JSON_APPEND()

Supported.

-

JSON_ARRAY()

Supported.

-

JSON_ARRAY_APPEND()

Supported.

-

JSON_ARRAY_INSERT()

Supported.

-

JSON_CONTAINS()

Supported.

-

JSON_CONTAINS_PATH()

Supported.

-

JSON_DEPTH()

Supported.

-

JSON_EXTRACT()

Supported.

-

JSON_INSERT()

Supported.

-

JSON_KEYS()

Supported.

-

JSON_LENGTH()

Supported.

-

JSON_MERGE()

Supported.

-

JSON_OBJECT()

Supported.

-

JSON_QUOTE()

Supported.

-

JSON_REMOVE()

Supported.

-

JSON_REPLACE()

Supported.

-

JSON_SEARCH()

Supported, with differences

GaussDB returns values of the text type, while MySQL returns values of the JSON type.

JSON_SET()

Supported.

-

JSON_TYPE()

Supported.

-

JSON_UNQUOTE()

Supported.

-

JSON_VALID()

Supported.

-