MySQL tutorial: JSON_QUOTE [EN]
top of page
CerebroSQL

MySQL: 

JSON_QUOTE

Syntax:
JSON_QUOTE(string)

Quotes a string as a JSON value by wrapping it with double quote
characters and escaping interior quote and other characters, then
returning the result as a utf8mb4 string. Returns NULL if the argument
is NULL.

This function is typically used to produce a valid JSON string literal
for inclusion within a JSON document.

Certain special characters are escaped with backslashes per the escape
sequences shown in
https://dev.mysql.com/doc/refman/8.0/en/json-modification-functions.htm
l#json-unquote-character-escape-sequences.

URL: https://dev.mysql.com/doc/refman/8.0/en/json-creation-functions.html

Example

mysql> SELECT JSON_QUOTE('null'), JSON_QUOTE('"null"');
+--------------------+----------------------+
| JSON_QUOTE('null') | JSON_QUOTE('"null"') |
+--------------------+----------------------+
| "null" | "\"null\"" |
+--------------------+----------------------+
mysql> SELECT JSON_QUOTE('[1, 2, 3]');
+-------------------------+
| JSON_QUOTE('[1, 2, 3]') |
+-------------------------+
| "[1, 2, 3]" |
+-------------------------+

bottom of page