> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kinetica.com/llms.txt
> Use this file to discover all available pages before exploring further.

# JSON Functions

<a id="sql-json-functions" />

<a id="sql-json-functions-scalar" />

## Scalar Functions

These functions can be applied to individual *json* column values, as well as
*array* & *string* columns.  However, for some functions to work as expected,
the *array* or *string* value may need to be cast to JSON first.

<AccordionGroup>
  <Accordion title="JSON(expr)" id="json-expr" defaultOpen>
    Casts the given `expr` to JSON data type

    Examples:

    <div>
      <table class="table w-full [&_td]:min-w-[150px] [&_th]:text-left [&_td[data-numeric]]:tabular-nums">
        <thead>
          <tr>
            <th>Function Call</th>
            <th>Result</th>
          </tr>
        </thead>

        <tbody>
          <tr>
            <td><code>JSON('\[1, 2, "C"]')</code></td>
            <td><code>\[1,2,"C"]</code></td>
          </tr>

          <tr>
            <td><code>JSON('\{"A": "B", "C": \{"D": 5, "F": 7}}')</code></td>
            <td><code>\{"A":"B","C":\{"D":5,"F":7}}</code></td>
          </tr>

          <tr>
            <td><code>JSON(null)</code></td>
            <td>*null*</td>
          </tr>
        </tbody>
      </table>
    </div>
  </Accordion>

  <Accordion title="JSON_ARRAY (value[,...] <null_hand>)" id="json_array-value-<null_hand>" defaultOpen>
    Creates a JSON array out of the given list of values.

    An optional `<null_hand>` parameter can be added to the end of the list to specify
    handling of *null* values, though, at present, this only exists for compatibility with
    other databases' syntax--the option will be ignored and all *null* values will be added
    to the array as *null*.  Accepted null handling options:

    * `NULL ON NULL`

    <Info>
      This function is only available in SQL or in the native API via
      [/execute/sql](/content/api/rest/execute_sql_rest).
    </Info>

    Examples:

    <div>
      <table class="table w-full [&_td]:min-w-[150px] [&_th]:text-left [&_td[data-numeric]]:tabular-nums">
        <thead>
          <tr>
            <th>Function Call</th>
            <th>Result</th>
          </tr>
        </thead>

        <tbody>
          <tr>
            <td><code>JSON\_ARRAY(1, 2, 'C')</code></td>
            <td><code>\[1,2,"C"]</code></td>
          </tr>

          <tr>
            <td><code>JSON\_ARRAY(JSON('\{"A": "B"}'), JSON('\{"C": 4}'))</code></td>
            <td><code>\[\{"A":"B"},\{"C":4}]</code></td>
          </tr>

          <tr>
            <td><code>JSON\_ARRAY(1, null, 'C' NULL ON NULL)</code></td>
            <td><code>\[1,null,"C"]</code></td>
          </tr>
        </tbody>
      </table>
    </div>
  </Accordion>

  <Accordion title="JSON_ARRAY_APPEND(arr, value)" id="json_array_append-arr-value" defaultOpen>
    Appends the given `value` to the given array `arr` of type string, array, or JSON

    Examples:

    <div>
      <table class="table w-full [&_td]:min-w-[150px] [&_th]:text-left [&_td[data-numeric]]:tabular-nums">
        <thead>
          <tr>
            <th>Function Call</th>
            <th>Result</th>
          </tr>
        </thead>

        <tbody>
          <tr>
            <td><code>JSON\_ARRAY\_APPEND('\[1, 2]', 'C')</code></td>
            <td><code>\[1,2,"C"]</code></td>
          </tr>

          <tr>
            <td><code>JSON\_ARRAY\_APPEND('\{"A": "B"}', JSON('\{"C": 4}'))</code></td>
            <td><code>\[\{"A":"B"},\{"C":4}]</code></td>
          </tr>
        </tbody>
      </table>
    </div>
  </Accordion>

  <Accordion title="JSON_ARRAY_CONTAINS (json, path, val)" id="json_array_contains-json-path-val" defaultOpen>
    Returns whether the given JSON `json` contains the primitive value `val` at the JSON
    query path, `path`

    Examples:

    <div>
      <table class="table w-full [&_td]:min-w-[150px] [&_th]:text-left [&_td[data-numeric]]:tabular-nums">
        <thead>
          <tr>
            <th>Function Call</th>
            <th>Result</th>
          </tr>
        </thead>

        <tbody>
          <tr>
            <td><code>JSON\_ARRAY\_CONTAINS('\[1, 2]', '\$', 2)</code></td>
            <td><code>true</code></td>
          </tr>

          <tr>
            <td><code>JSON\_ARRAY\_CONTAINS('\[1, 2]', '\$', 'C')</code></td>
            <td><code>false</code></td>
          </tr>

          <tr>
            <td><code>JSON\_ARRAY\_CONTAINS('\{"A": \[2, 3]}', '\$.A', 2)</code></td>
            <td><code>true</code></td>
          </tr>

          <tr>
            <td><code>JSON\_ARRAY\_CONTAINS('\{"A": \{"B": \[3, 4]}}', '\$\["A"]\["B"]', 4)</code></td>
            <td><code>true</code></td>
          </tr>
        </tbody>
      </table>
    </div>
  </Accordion>

  <Accordion title="JSON_CARDINALITY(json)" id="json_cardinality-json" defaultOpen>
    Alias for `JSON_LENGTH`
  </Accordion>

  <Accordion title="JSON_EXISTS(json, path)" id="json_exists-json-path" defaultOpen>
    Returns whether the given JSON `json` contains the JSON query path, `path`

    Examples:

    <div>
      <table class="table w-full [&_td]:min-w-[150px] [&_th]:text-left [&_td[data-numeric]]:tabular-nums">
        <thead>
          <tr>
            <th>Function Call</th>
            <th>Result</th>
          </tr>
        </thead>

        <tbody>
          <tr>
            <td><code>JSON\_EXISTS('\[1, 2]', '\$')</code></td>
            <td><code>true</code></td>
          </tr>

          <tr>
            <td><code>JSON\_EXISTS('\[1, 2]', '\$.A')</code></td>
            <td><code>false</code></td>
          </tr>

          <tr>
            <td><code>JSON\_EXISTS('\{"A": \[2, 3]}', '\$.A')</code></td>
            <td><code>true</code></td>
          </tr>

          <tr>
            <td><code>JSON\_EXISTS('\{"A": \{"B": 3, "D": 5}}', '\$\["A"]\["D"]')</code></td>
            <td><code>true</code></td>
          </tr>
        </tbody>
      </table>
    </div>
  </Accordion>

  <Accordion title="JSON_KEYS(json, path)" id="json_keys-json-path" defaultOpen>
    Returns the set of keys of the JSON object at the given `path` in `json`; null, if the
    path doesn't exist or contains a non-object (non-map) value

    Examples:

    <div>
      <table class="table w-full [&_td]:min-w-[150px] [&_th]:text-left [&_td[data-numeric]]:tabular-nums">
        <thead>
          <tr>
            <th>Function Call</th>
            <th>Result</th>
          </tr>
        </thead>

        <tbody>
          <tr>
            <td><code>JSON\_KEYS('\{}', '\$')</code></td>
            <td><code>\[]</code></td>
          </tr>

          <tr>
            <td><code>JSON\_KEYS('\[1, 2]', '\$.A')</code></td>
            <td>*null*</td>
          </tr>

          <tr>
            <td><code>JSON\_KEYS('\{"A": \[2, 3]}', '\$')</code></td>
            <td><code>\["A"]</code></td>
          </tr>

          <tr>
            <td><code>JSON\_KEYS('\{"A": \{"B": 3, "D": 5}}', '\$\["A"]')</code></td>
            <td><code>\["B","D"]</code></td>
          </tr>

          <tr>
            <td><code>JSON\_KEYS('\{"A": \{"B": 3, "D": 5}}', '\$\["A"]\["D"]')</code></td>
            <td>*null*</td>
          </tr>

          <tr>
            <td><code>JSON\_KEYS('\{"A": \{"B": 3, "D": \{}}}', '\$\["A"]\["D"]')</code></td>
            <td><code>\[]</code></td>
          </tr>
        </tbody>
      </table>
    </div>
  </Accordion>

  <Accordion title="JSON_LENGTH(json[, path])" id="json_length-json-path" defaultOpen>
    Returns the number of items in the top-level object of the given `json`, or at the
    level of the optional JSON `path`

    Examples:

    <div>
      <table class="table w-full [&_td]:min-w-[150px] [&_th]:text-left [&_td[data-numeric]]:tabular-nums">
        <thead>
          <tr>
            <th>Function Call</th>
            <th>Result</th>
          </tr>
        </thead>

        <tbody>
          <tr>
            <td><code>JSON\_LENGTH('\{}')</code></td>
            <td><code>0</code></td>
          </tr>

          <tr>
            <td><code>JSON\_LENGTH('\[]')</code></td>
            <td><code>0</code></td>
          </tr>

          <tr>
            <td><code>JSON\_LENGTH('\[1, 2]')</code></td>
            <td><code>2</code></td>
          </tr>

          <tr>
            <td><code>JSON\_LENGTH('\{"A": \[2, 3]}')</code></td>
            <td><code>1</code></td>
          </tr>

          <tr>
            <td><code>JSON\_LENGTH('\{"A": \{"B": 3}, "D": "E"}')</code></td>
            <td><code>2</code></td>
          </tr>

          <tr>
            <td><code>JSON\_LENGTH('\{"A": \[2, 3]}', '\$.A')</code></td>
            <td><code>2</code></td>
          </tr>

          <tr>
            <td><code>JSON\_LENGTH('\{"A": \{"B": 3}, "D": "E"}', '\$.A')</code></td>
            <td><code>1</code></td>
          </tr>
        </tbody>
      </table>
    </div>
  </Accordion>

  <Accordion title="JSON_MAKE_ARRAY(value)" id="json_make_array-value" defaultOpen>
    Creates a JSON array out of the given `value`

    Examples:

    <div>
      <table class="table w-full [&_td]:min-w-[150px] [&_th]:text-left [&_td[data-numeric]]:tabular-nums">
        <thead>
          <tr>
            <th>Function Call</th>
            <th>Result</th>
          </tr>
        </thead>

        <tbody>
          <tr>
            <td><code>JSON\_MAKE\_ARRAY(1)</code></td>
            <td><code>\[1]</code></td>
          </tr>

          <tr>
            <td><code>JSON\_MAKE\_ARRAY(JSON\_ARRAY(1,2,3))</code></td>
            <td><code>\[\[1,2,3]]</code></td>
          </tr>

          <tr>
            <td><code>JSON\_MAKE\_ARRAY(JSON('\{"A": "B"}'))</code></td>
            <td><code>\[\{"A":"B"}]</code></td>
          </tr>
        </tbody>
      </table>
    </div>
  </Accordion>

  <Accordion title="JSON_OBJECT (value[,...] <null_hand>)" id="json_object-value-<null_hand>" defaultOpen>
    Creates a JSON map out of the given `value` set

    An optional `<null_hand>` parameter can be added to the end of the list to specify
    handling of *null* values, though, at present, this only exists for compatibility with
    other databases' syntax--the option will be ignored and all *null* values will be added
    to the array as *null*.  Accepted null handling options:

    * `NULL ON NULL`

    <Info>
      This function is only available in SQL or in the native API via
      [/execute/sql](/content/api/rest/execute_sql_rest).
    </Info>

    Examples:

    <div>
      <table class="table w-full [&_td]:min-w-[150px] [&_th]:text-left [&_td[data-numeric]]:tabular-nums">
        <thead>
          <tr>
            <th>Function Call</th>
            <th>Result</th>
          </tr>
        </thead>

        <tbody>
          <tr>
            <td><code>JSON\_OBJECT()</code></td>
            <td><code>\{}</code></td>
          </tr>

          <tr>
            <td><code>JSON\_OBJECT('A': 2)</code></td>
            <td><code>\{"A":2}</code></td>
          </tr>

          <tr>
            <td><code>JSON\_OBJECT('A' VALUE 2)</code></td>
            <td><code>\{"A":2}</code></td>
          </tr>

          <tr>
            <td><code>JSON\_OBJECT(KEY 'A' VALUE 2)</code></td>
            <td><code>\{"A":2}</code></td>
          </tr>

          <tr>
            <td><code>JSON\_OBJECT('A': 'B', 'C': null NULL ON NULL)</code></td>
            <td><code>\{"A":"B","C":null}</code></td>
          </tr>
        </tbody>
      </table>
    </div>
  </Accordion>

  <Accordion title="JSON_PRETTY(json)" id="json_pretty-json" defaultOpen>
    Returns a formatted version of the given `json` object

    Examples:

    <div>
      <table class="table w-full [&_td]:min-w-[150px] [&_th]:text-left [&_td[data-numeric]]:tabular-nums">
        <tbody>
          <tr>
            <td>**Function Call**</td>
            <td><code>JSON\_PRETTY('\[1,2,"C"]')</code></td>
          </tr>

          <tr>
            <td>**Return**</td>
            <td><pre><code>\[
            1,
            2,
            "C"
            ]</code></pre></td>
          </tr>
        </tbody>
      </table>
    </div>

    <div>
      <table class="table w-full [&_td]:min-w-[150px] [&_th]:text-left [&_td[data-numeric]]:tabular-nums">
        <tbody>
          <tr>
            <td>**Function Call**</td>
            <td><code>JSON\_PRETTY('\{"A": "B", "C": \{"D": 5, "F": 7}}')</code></td>
          </tr>

          <tr>
            <td>**Return**</td>
            <td><pre><code>\{
            "A": "B",
            "C": \{
            "D": 5,
            "F": 7
            }
            ]</code></pre></td>
          </tr>
        </tbody>
      </table>
    </div>
  </Accordion>

  <Accordion title="JSON_QUERY (json, path [<return>])" id="json_query-json-path-<return>" defaultOpen>
    Returns the JSON object at the given `path` in `json`; null, if the path doesn't exist
    or contains a primitive (non-object) value

    An optional `return` clause can be added to the end of the path to specify the return type
    of the object found, as well as the error handling for the object lookup.  The format of the
    clause is:

    ```
    [<wrapper> WRAPPER] [<empty_hand> ON EMPTY] [<error hand> ON ERROR]
    ```

    <Info>
      Return clause is only available in SQL or in the native API via
      [/execute/sql](/content/api/rest/execute_sql_rest).
    </Info>

    <div>
      <table class="table w-full [&_td]:min-w-[150px] [&_th]:text-left [&_td[data-numeric]]:tabular-nums">
        <thead>
          <tr>
            <th>Parameter</th>
            <th>Description</th>
          </tr>
        </thead>

        <tbody>
          <tr>
            <td><code>\<wrapper></code></td>
            <td>Whether the returned object(s) should be wrapped in an array before being returned Valid wrapping schemes include: <ul><li><code>WITHOUT \[ARRAY]</code> - no wrapper is applied *(default)*</li><li><code>WITH \[UNCONDITIONAL] \[ARRAY]</code> - return the object(s) in an array</li><li><code>WITH CONDITIONAL \[ARRAY]</code> - if returning a single object, don't wrap it; if returning multiple objects, wrap them in an array</li></ul></td>
          </tr>

          <tr>
            <td><code>\<empty hand></code></td>
            <td>The scheme to use for handling empty returned objects Valid schemes include: <ul><li><code>NULL</code> - return *null* *(default)*</li><li><code>ERROR</code> - throw an error</li><li><code>EMPTY ARRAY</code> - return an empty array</li><li><code>EMPTY OBJECT</code> - return an empty object</li></ul></td>
          </tr>

          <tr>
            <td><code>\<error hand></code></td>
            <td>The scheme to use for handling errors in looking up the object Valid schemes include: <ul><li><code>NULL</code> - return *null* *(default)*</li><li><code>ERROR</code> - throw an error</li><li><code>EMPTY ARRAY</code> - return an empty array</li><li><code>EMPTY OBJECT</code> - return an empty object</li></ul></td>
          </tr>
        </tbody>
      </table>
    </div>

    Examples:

    <div>
      <table class="table w-full [&_td]:min-w-[150px] [&_th]:text-left [&_td[data-numeric]]:tabular-nums">
        <thead>
          <tr>
            <th>Function Call</th>
            <th>Result</th>
          </tr>
        </thead>

        <tbody>
          <tr>
            <td><code>JSON\_QUERY('\[1, 2]', '\$')</code></td>
            <td><code>\[1,2]</code></td>
          </tr>

          <tr>
            <td><code>JSON\_QUERY('\[1, 2]', '\$.A')</code></td>
            <td>*null*</td>
          </tr>

          <tr>
            <td><code>JSON\_QUERY('\{"A": \[2, 3]}', '\$.A')</code></td>
            <td><code>\[2,3]</code></td>
          </tr>

          <tr>
            <td><code>JSON\_QUERY('\{"A": \{"B": 3, "D": 5}}', '\$\["A"]')</code></td>
            <td><code>\{"B":3,"D":5}</code></td>
          </tr>

          <tr>
            <td><code>JSON\_QUERY('\{"A": \{"B": 3, "D": 5}}', '\$\["A"]\["D"]')</code></td>
            <td>*null*</td>
          </tr>

          <tr>
            <td><code>JSON\_QUERY('\{"A": \{"B": 3, "D": \[5, 6]}}', '\$\["A"]\["D"]')</code></td>
            <td><code>\[5,6]</code></td>
          </tr>

          <tr>
            <td><code>JSON\_QUERY('\{"A": \[]}', '\$.B'  EMPTY ARRAY ON EMPTY)</code></td>
            <td><code>\[]</code></td>
          </tr>

          <tr>
            <td><code>JSON\_QUERY('\{"A": 0}', '\$.A'  EMPTY OBJECT ON ERROR)</code></td>
            <td><code>\{}</code></td>
          </tr>

          <tr>
            <td><code>JSON\_QUERY('\{"A": 2, "C": 4}', '\$.\*')</code></td>
            <td>*null*</td>
          </tr>

          <tr>
            <td><code>JSON\_QUERY('\{"A": 2, "C": 4}', '\$.\*' WITH WRAPPER)</code></td>
            <td><code>\[2,4]</code></td>
          </tr>
        </tbody>
      </table>
    </div>
  </Accordion>

  <Accordion title="JSON_REPLACE(json, path, repl)" id="json_replace-json-path-repl" defaultOpen>
    Returns the given `json` with the value at the JSON path `path` replaced with the
    replacement value `repl`

    Examples:

    <div>
      <table class="table w-full [&_td]:min-w-[150px] [&_th]:text-left [&_td[data-numeric]]:tabular-nums">
        <thead>
          <tr>
            <th>Function Call</th>
            <th>Result</th>
          </tr>
        </thead>

        <tbody>
          <tr>
            <td><code>JSON\_REPLACE('\[1, 2]', '\$', '\[3, 4]')</code></td>
            <td><code>\[3,4]</code></td>
          </tr>

          <tr>
            <td><code>JSON\_REPLACE('\[1, 2]', '\$.A', '"B"')</code></td>
            <td><code>\[1,2]</code></td>
          </tr>

          <tr>
            <td><code>JSON\_REPLACE('\{"A": \[2, 3]}', '\$.A', '\{"D": 5}')</code></td>
            <td><code>\{"A":\{"D":5}}</code></td>
          </tr>

          <tr>
            <td><code>JSON\_REPLACE('\{"A": \{"B": 3}}', '\$\["A"]', '"D"')</code></td>
            <td><code>\{"A":"D"}</code></td>
          </tr>

          <tr>
            <td><code>JSON\_REPLACE('\{"A": \{"B": \[3, 4]}}', '\$\["A"]\["B"]', 5)</code></td>
            <td><code>\{"A":\{"B":5}}</code></td>
          </tr>
        </tbody>
      </table>
    </div>
  </Accordion>

  <Accordion title="JSON_TYPE(expr)" id="json_type-expr" defaultOpen>
    Returns the JSON type of the given `expr`

    <div>
      <table class="table w-full [&_td]:min-w-[150px] [&_th]:text-left [&_td[data-numeric]]:tabular-nums">
        <thead>
          <tr>
            <th>Expression Type</th>
            <th>JSON Type</th>
          </tr>
        </thead>

        <tbody>
          <tr>
            <td><code>BOOLEAN</code></td>
            <td><code>BOOLEAN</code></td>
          </tr>

          <tr>
            <td><ul><li><code>TINYINT</code></li><li><code>SMALLINT</code></li><li><code>INTEGER</code></li><li><code>BIGINT</code></li><li><code>UNSIGNED BIGINT</code></li></ul></td>
            <td><code>LONG</code></td>
          </tr>

          <tr>
            <td><ul><li><code>REAL</code></li><li><code>DOUBLE</code></li></ul></td>
            <td><code>DOUBLE</code></td>
          </tr>

          <tr>
            <td><ul><li><code>JSON</code></li><li><code>VARCHAR</code></li></ul></td>
            <td><ul><li><code>BOOLEAN</code> - if <code>true</code> or <code>false</code></li><li><code>LONG</code> - if an integer value</li><li><code>DOUBLE</code> - if a floating-point value</li><li><code>STRING</code> - if a double-quoted literal</li><li><code>OBJECT</code> - if a JSON map</li><li><code>ARRAY</code> - if a JSON array</li></ul></td>
          </tr>

          <tr>
            <td><code>ARRAY</code> *(any)*</td>
            <td><code>ARRAY</code></td>
          </tr>
        </tbody>
      </table>
    </div>
  </Accordion>

  <Accordion title="JSON_VALUE (json, path [return])" id="json_value-json-path-return" defaultOpen>
    Returns the JSON value at the given `path` in `json`; null, if the path doesn't exist
    or contains an object (non-primitive) value

    An optional `return` clause can be added to the end of the path to specify the return type
    of the value found, as well as the error handling for the value lookup.  The format of the
    clause is:

    ```
    [RETURNING <type>] [<empty_hand> ON EMPTY] [<error hand> ON ERROR]
    ```

    <Info>
      Return clause is only available in SQL or in the native API via
      [/execute/sql](/content/api/rest/execute_sql_rest).
    </Info>

    <div>
      <table class="table w-full [&_td]:min-w-[150px] [&_th]:text-left [&_td[data-numeric]]:tabular-nums">
        <thead>
          <tr>
            <th>Parameter</th>
            <th>Description</th>
          </tr>
        </thead>

        <tbody>
          <tr>
            <td><code>\<type></code></td>
            <td>The JSON type of the value to return; if the value is not already of that type, it will be cast to that type, if possible Valid types include: <ul><li><code>BOOLEAN</code></li><li><code>LONG</code></li><li><code>DOUBLE</code></li><li><code>STRING</code></li></ul></td>
          </tr>

          <tr>
            <td><code>\<empty hand></code></td>
            <td>The scheme to use for handling empty returned values Valid schemes include: <ul><li><code>NULL</code> - return *null* *(default)*</li><li><code>ERROR</code> - throw an error</li><li><code>DEFAULT \<expr></code> - return the given expression <code>expr</code></li></ul></td>
          </tr>

          <tr>
            <td><code>\<error hand></code></td>
            <td>The scheme to use for handling errors in looking up the value Valid schemes include: <ul><li><code>NULL</code> - return *null* *(default)*</li><li><code>ERROR</code> - throw an error</li><li><code>DEFAULT \<expr></code> - return the given expression <code>expr</code></li></ul></td>
          </tr>
        </tbody>
      </table>
    </div>

    Examples:

    <div>
      <table class="table w-full [&_td]:min-w-[150px] [&_th]:text-left [&_td[data-numeric]]:tabular-nums">
        <thead>
          <tr>
            <th>Function Call</th>
            <th>Result</th>
          </tr>
        </thead>

        <tbody>
          <tr>
            <td><code>JSON\_VALUE('1', '\$')</code></td>
            <td><code>1</code></td>
          </tr>

          <tr>
            <td><code>JSON\_VALUE('\[1, 2]', '\$.A')</code></td>
            <td>*null*</td>
          </tr>

          <tr>
            <td><code>JSON\_VALUE('\["A", "B"]', '\$.1')</code></td>
            <td><code>B</code></td>
          </tr>

          <tr>
            <td><code>JSON\_VALUE('\{"A": \[2, 3]}', '\$\["A"]\["1"]')</code></td>
            <td><code>3</code></td>
          </tr>

          <tr>
            <td><code>JSON\_VALUE('\{"A": \{"B": 3, "D": 5}}', '\$\["A"]\["D"]')</code></td>
            <td><code>5</code></td>
          </tr>

          <tr>
            <td><code>JSON\_VALUE('\{"A": \{"B": 3, "D": \[5, 6]}}', '\$.A.D.1')</code></td>
            <td><code>6</code></td>
          </tr>

          <tr>
            <td><code>JSON\_VALUE('1', '\$' RETURNING DOUBLE)</code></td>
            <td><code>1.0</code></td>
          </tr>

          <tr>
            <td><code>JSON\_VALUE('\{"A": \[]}', '\$.B' DEFAULT '\<null>' ON EMPTY)</code></td>
            <td><code>\<null></code></td>
          </tr>

          <tr>
            <td><code>JSON\_VALUE('\{"A": \[]}', '\$.A' ERROR ON ERROR)</code></td>
            <td>*error returned*</td>
          </tr>
        </tbody>
      </table>
    </div>
  </Accordion>
</AccordionGroup>

<a id="sql-json-functions-agg" />

## Aggregation Functions

The following functions can be used on [JSON](/content/concepts/json)
columns within [aggregations](/content/sql/query/aggregation#sql-aggregation).

<AccordionGroup>
  <Accordion title="JSON_ARRAYAGG(expr)" id="json_arrayagg-expr" defaultOpen>
    Combines column values within a group into a single JSON array of those values.

    See [examples](/content/concepts/json#json-func-agg-ex-agg).
  </Accordion>

  <Accordion title="JSON_ARRAYAGG_DISTINCT(expr)" id="json_arrayagg_distinct-expr" defaultOpen>
    Combines column values within a group into a single JSON array of those values,
    removing any duplicates.

    See [examples](/content/concepts/json#json-func-agg-ex-agg-dist).
  </Accordion>

  <Accordion title="JSON_COLLECT_SET(expr)" id="json_collect_set-expr" defaultOpen>
    Alias for `JSON_ARRAYAGG_DISTINCT`.
  </Accordion>
</AccordionGroup>
