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β
Parameters | Description |
---|---|
<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 Sequence | Character Represented by Sequence |
---|---|
" | A double quote (") character |
\b | A backspace character |
\f | A formfeed character |
\n | A newline (linefeed) character |
\r | A carriage return character |
\t | A tab character |
\ | A backslash () character |
\uxxxx | UTF-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 |
+-----------------------------------------+