---
title: "JSONELEMENT"
description: "The JSONELEMENT SQL function returns the text as a JSON value assignment, with the JSON representation of special characters replaced by their original\u2026"
language: en
source_language: en
translation_state: complete
canonical: https://documentation.invantive.eu/en/docs/invantive-universalsql/grammar/sql-functions/jsonelement
original: https://documentation.invantive.eu/en/docs/invantive-universalsql/grammar/sql-functions/jsonelement
updated: 2026-10-08T00:00:00Z
license: https://documentation.invantive.eu/en/
---

## 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`): `true` returns `null` for a `null` input, `false` returns the assignment with the JSON literal `null`. Defaults to `true`. A constant and the value of a column give the same result.

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
```