---
title: "JSONENCODE"
description: "La funzione SQL JSONENCODE restituisce il testo codificato in JSON del testo normale, con i caratteri speciali escapati secondo la rappresentazione JSON."
language: it
source_language: en
translation_state: complete
canonical: https://documentation.invantive.eu/it/docs/invantive-universalsql/grammar/sql-functions/jsonencode
original: https://documentation.invantive.eu/en/docs/invantive-universalsql/grammar/sql-functions/jsonencode
updated: 2026-12-02T12:10:27Z
license: https://documentation.invantive.eu/it/
---

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

## Scopo
La funzione SQL `JSONENCODE` restituisce il testo codificato in JSON di un testo normale, con i caratteri speciali sottoposti a escape secondo la rappresentazione JSON.

Vedi anche [[JSONDECODE]] e [[JSONELEMENT]].

Parametri:
- Input (`ANY`): l'input che verrà convertito dal proprio tipo in formato JSON.

Restituisce: un testo che rappresenta l'input codificato in formato JSON come `varchar2`. Un input `null` restituisce il letterale JSON `null`, sia che si tratti di una costante sia che si tratti del valore di una Colonna; pertanto, un testo JSON costruito tramite concatenazione rimane valido.

## Esempi
L'esempio seguente recupera la rappresentazione JSON di un testo:
```sql
select jsonencode('Special characters such as backslash (\) and quote (").')

----------------
"Special characters such as backslash (\\) and quote (\")."
```
L'esempio seguente crea un oggetto JSON per ogni riga, anche per le righe prive di valore:
```sql
select '{"name": ' || jsonencode(v.name) || '}'
from   ( select 'Invantive' name from dual@DataDictionary
         union all
         select null from dual@DataDictionary
       ) v

----------------
{"name": "Invantive"}
{"name": null}
```
L'esempio seguente recupera la rappresentazione JSON di una data/ora:
```sql
select jsonencode(sysdateutc)

----------------
"2026-06-09T11:14:32.4407146Z"
```

