Skip to main content

JSON_UNQUOTE

Description

This function unquotes a JSON value and returns the result as a utf8mb4 string. If the argument is NULL, it will return NULL.

Syntax

JSON_UNQUOTE (<a>)

Parameters

ParametersDescription
<a>The element to be unquoted.

Return Values

Returns a utf8mb4 string. Special cases are as follows:

  • If the passed parameter is NULL, return NULL.
  • If the passed parameter is not a value with double quotes, the value itself will be returned.
  • If the passed parameter is not a string, it will be automatically converted to a string and then the value itself will be returned.

Escape sequences within a string as shown in the following table will be recognized. Backslashes will be ignored for all other escape sequences.

Escape SequenceCharacter Represented by Sequence
"A double quote (") character
\bA backspace character
\fA formfeed character
\nA newline (linefeed) character
\rA carriage return character
\tA tab character
\A backslash () character
\uxxxxUTF-8 bytes for Unicode value XXXX

Examples

SELECT json_unquote('"doris"');
+-------------------------+
| json_unquote('"doris"') |
+-------------------------+
| doris |
+-------------------------+
SELECT json_unquote('[1, 2, 3]');
+---------------------------+
| json_unquote('[1, 2, 3]') |
+---------------------------+
| [1, 2, 3] |
+---------------------------+
SELECT json_unquote(null);
+--------------------+
| json_unquote(NULL) |
+--------------------+
| NULL |
+--------------------+
SELECT json_unquote('"\\ttest"');
+--------------------------+
| json_unquote('"\ttest"') |
+--------------------------+
| test |
+--------------------------+
select json_unquote('"doris');
+------------------------+
| json_unquote('"doris') |
+------------------------+
| "doris |
+------------------------+
select json_unquote('doris');
+-----------------------+
| json_unquote('doris') |
+-----------------------+
| doris |
+-----------------------+
select json_unquote(1);
+-----------------------------------------+
| json_unquote(cast(1 as VARCHAR(65533))) |
+-----------------------------------------+
| 1 |
+-----------------------------------------+