JSON_FORMAT
All functions > JSON > JSON_FORMAT
Returns the given JSON expression as a string.
Signatures
Returns: A VARCHAR representation of the JSON value
JSON_FORMAT(expr: JSON) → VARCHAR sql
| Parameter | Type | Required | Description |
|---|---|---|---|
expr | JSON | Yes | The JSON expression to convert to string |
Notes
- Converts JSON values to their string representation
- Preserves JSON structure in the string output
- Objects are formatted as JSON object strings
- Arrays are formatted as JSON array strings
- Primitives are converted to their string representation
- Useful for storing or transmitting JSON as text
- Inverse of JSON_PARSE
- Output is valid JSON format
Examples
FeatureQL
SELECT
f1 := JSON_FORMAT(JSON_PARSE('{"name": "Alice", "age": 30}')), -- Convert JSON object to string
f2 := JSON_FORMAT(JSON_PARSE('[1, 2, 3]')), -- Convert JSON array to string
f3 := JSON_FORMAT(JSON_PARSE('"hello"')) -- Convert JSON string to string
;Result
| f1 VARCHAR | f2 VARCHAR | f3 VARCHAR |
|---|---|---|
| {"name": "Alice", "age": 30} | [1, 2, 3] | "hello" |
On this page