## Syntax
```mermaid
%%{init: {
'theme': 'base',
'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' },
'themeVariables': {
'fontSize': '11px',
'fontFamily': 'Arial'
}
}}%%
flowchart LR
Start((START)) --> JSONELEMENT[JSONELEMENT]:::quoted
JSONELEMENT --> End((END))
```
## Purpose
The `JSONELEMENT` SQL function returns the text as a JSON value assignment, with the JSON representation of special characters replaced by their original meaning.
See also [[JSONDECODE]] and [[JSONENCODE]].
Parameters:
- Name (`varchar2`): the name of the JSON element.
- Input (`ANY`): the input which will be encoded to a JSON value.
- Empty on Null (optional, `boolean`): whether to use a JSON value assignment for a `null` input. Defaults to `true`.
Returns: a text which is the input encoded as a JSON value assignment as `varchar2`.
## Examples
The following example retrieves the text representation of a JSON value assignment for a `guid`:
```sql
select jsonelement('id', newid())
----------------
"id": "509951c7-6f95-4c8b-808e-a47b8b0739e1"
```
The following example retrieves the text representation of a JSON value assignment for a `datetime`:
```sql
select jsonelement('date', trunc(sysdateutc, -2))
----------------
"date": "2026-01-01T00:00:00Z"
```
The following example retrieves the text representation of a JSON value assignment for a `varchar2`:
```sql
select jsonelement('name', null, false)
----------------
"name": null
```