JSON_ PRETTY
Formats a JSON string into a more human-readable, "pretty-printed" format.
This function takes a JSON value and returns its string representation with added whitespace (spaces, tabs, newlines) to make it easier to read. If the input json is not a well-formed JSON value, this function will throw an error.
The optional format argument is a string that specifies how to format the output. As of now, SQLite does not use this argument, but it is included for future compatibility. The pretty-printed result is the same regardless of whether this argument is provided.
Example:
val jsonCol = jsonColumn("data") // Contains '{"a":1,"b":[2,3]}'
// SELECT JSON_PRETTY(data)
// Result might be:
// {
// "a": 1,
// "b": [
// 2,
// 3
// ]
// }
select(JSON_PRETTY(jsonCol)).from(MyTable).execute()
// Example with a JSON literal
val compactJson = JSON("""{"key":"value","arr":[1,2]}""")
// SELECT JSON_PRETTY('{"key":"value","arr":[1,2]}')
select(JSON_PRETTY(compactJson)).execute()Content copied to clipboard
Return
A KQLiteColumn of the same type T containing the pretty-printed JSON string.
Author
MOHAMMAD AZIM ANSARI
Parameters
json
The KQLiteJson column to format.
format
An optional string argument, to control formatting.