SQLite json() Function

The SQLite json() function validates the string specified by the parameter and converts it to a minimal JSON string, with all unnecessary whitespace removed.

Syntax

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

json(str)

Parameters

str

Optional. The text to convert.

Return value

The SQLite json() function returns a minimal JSON string (with all unnecessary whitespace removed) transformed from the parameter.

Examples

The following example shows the basic usage of the SQLite json() function:

SELECT json('[1, 2, [3, 4]]');
json('[1, 2, [3, 4]]')
----------------------
[1,2,[3,4]]

Let’s look at another example:

SELECT json(' { "this" : "is", "a": [ "test" ] } ');
json(' { "this" : "is", "a": [ "test" ] } ')
--------------------------------------------
{"this":"is","a":["test"]}