Documentación de Invantiveparte de Invantive Cloud
Foros de Soporte de InvantiveIniciar Sesión / Registrarse

JSONFORMAT

Sintaxis

%%{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))

Propósito

La función SQL JSONFORMAT formatea el texto JSON utilizando sangría.

Véanse también JSONDECODE, JSONELEMENT, JSONENCODE y XMLFORMAT.

Parámetros:

  • Json (varchar2): texto JSON que se va a formatear.

Devuelve: el texto JSON formateado. Devuelve null cuando la entrada es null o está vacía.

Ejemplos

El siguiente ejemplo formatea un texto JSON compacto:

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

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

El siguiente ejemplo formatea de forma legible un texto JSON compacto que contiene un array; cada elemento del array se coloca en su propia línea:

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

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