Syntax
Parameters
json_object_expr: The expression that represents the JSON object. The object can be a JSON column, a string containing valid JSON, or a JSON object produced by a JSON constructor function such as PARSE_JSON.
Return value
Returns the formatted JSON document as a string.
- Returns NULL if the argument is NULL.
- The returned string includes newlines and spaces for indentation.
- Object keys are sorted alphabetically in the output.
Examples
Example 1: Format a simple JSON object.Usage notes
- Indentation: The function adds standard indentation (spaces) and newlines to make the JSON structure visual.
- Key Sorting: JSON object keys are sorted alphabetically in the output string. This is standard behavior for the underlying JSON processing library (VelocyPack).
- Null Handling: If the input is SQL NULL, the function returns NULL.
- Data Types: It supports formatting of standard JSON types including Objects, Arrays, Strings, Numbers, Booleans, and Nulls.