Skip to main content

JSON_QUOTE

Converts a SQL value to its JSON representation: a string is enclosed in double quotes with special characters escaped, a number is returned as a JSON number, and NULL as JSON null.

See also:
[SELECT] [QUOTE] [JSON_OBJECT]


Syntax​

SELECT JSON_QUOTE(value) FROM <multipartIdentifier>;

Arguments​

value
A string, number or NULL.

Return Value(s)​

Returns a JSON value as a string.


Examples​

Quote values as JSON​

The embedded double quotes are escaped:

SELECT JSON_QUOTE('say "hi"') AS a, JSON_QUOTE(3.5) AS b, JSON_QUOTE(NULL) AS c;
|--------------|-----|------|
| a | b | c |
|--------------|-----|------|
| "say \"hi\"" | 3.5 | null |
|--------------|-----|------|

For more information, see https://www.sqlite.org/json1.html#jquote