SQLite json_quote() Function

The SQLite json_quote() function converts the SQL value specified by the parameter to the corresponding JSON representation.

Syntax

Here is the syntax of the SQLite json_quote() function:

json_quote(x)

Parameters

x

Required. A number or a string.

Return value

The json_quote() function returns the JSON representation of the SQL value specified by the parameter.

If the parameter x is provided by another JSON function, the json_quote() function does nothing and returns the parameter.

If the parameter is NULL, the json_quote() function returns NULL.

Examples

Here are some examples to show the usages of json_quote().

SELECT
    json_quote(123.1),
    json_quote('abc'),
    json_quote('[1]'),
    json_quote(NULL);
json_quote(123.1) = 123.1
json_quote('abc') = "abc"
json_quote('[1]') = "[1]"
 json_quote(NULL) = null

If the parameter x is provided by another JSON function, the json_quote() function does nothing and returns the parameter, for example:

SELECT json_quote(json('[1]'));
json_quote(json('[1]')) = [1]