Documentation Invantiveune partie de Invantive cloud
Forums d'Invantive SupportConnectez-vous/inscrivez-vous

JSONFORMAT

Syntaxe

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

Objet

La fonction SQL JSONFORMAT formate le texte JSON à l'aide d'indentations.

Voir également JSONDECODE, JSONELEMENT, JSONENCODE et XMLFORMAT.

Paramètres :

  • Json (varchar2) : texte JSON à formater.

Renvoie : le texte JSON formaté. Renvoie null lorsque l'entrée est null ou vide.

Exemples

L'exemple suivant formatise un texte JSON compact :

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

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

L'exemple suivant formate de manière lisible un texte JSON compact contenant un tableau ; chaque élément du tableau est placé sur une ligne distincte :

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

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