JSON
Checks that its argument is valid JSON and returns it in canonical, minified form. JSON5 input, such as unquoted keys, is accepted and converted to standard JSON.
See also:
[SELECT] [JSON_VALID] [JSON_PRETTY]
Syntax
SELECT JSON(json_value) FROM <multipartIdentifier>;
Arguments
json_value
A JSON or JSON5 string.
Return Value(s)
Returns a JSON string. An argument that is not valid JSON or JSON5 raises an error; use JSON_VALID to test a value first.
Examples
Minify a JSON value
Whitespace is removed:
SELECT JSON(' { "a" : [1, 2] } ') AS v;
|-------------|
| v |
|-------------|
| {"a":[1,2]} |
|-------------|
Convert JSON5 to JSON
The unquoted key is quoted in the result:
SELECT JSON('{a:1}') AS v;
|---------|
| v |
|---------|
| {"a":1} |
|---------|
For more information, see https://www.sqlite.org/json1.html#jmini