invantive documentationpart of invantive cloud
Invantive Support ForumsLog In / Sign Up

JSONFORMAT

Syntax

%%{init: {
  'theme': 'base',
  'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' },
  'themeVariables': {
    'fontSize': '11px',
    'fontFamily': 'Arial'
  }
}}%%
flowchart LR
    Start((START)) --> JSONFORMAT[JSONFORMAT]:::quoted
    JSONFORMAT --> End((END))

Purpose

The JSONFORMAT SQL function pretty-prints JSON text using indentation.

See also JSONDECODE, JSONELEMENT, JSONENCODE and XMLFORMAT.

Parameters:

  • Json (varchar2): JSON text to pretty-print.

Returns: the pretty-printed JSON text. Returns null when the input is null or empty.

Examples

The following example pretty-prints a compact JSON text:

select jsonformat('{"name":"peter","age":21}')

-------------------
{
  "name": "peter",
  "age": 21
}

The following example pretty-prints a compact JSON text containing an array; each array element is placed on its own line:

select jsonformat('{"name":"peter","tags":["sql","json"]}')

-------------------
{
  "name": "peter",
  "tags": [
    "sql",
    "json"
  ]
}