OceanBase logo

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Resources

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS

OceanBase Cloud

OceanBase Database

Tools

Connectors and Middleware

QUICK START

OceanBase Cloud

OceanBase Database

BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Company

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

International - English
中国站 - 简体中文
日本 - 日本語
Sign In
Start on Cloud

A unified distributed database ready for your transactional, analytical, and AI workloads.

DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS
OceanBase CloudOceanBase Database
ToolsConnectors and Middleware
QUICK START
OceanBase CloudOceanBase Database
BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

Start on Cloud
编组
All Products
    • Databases
    • iconOceanBase Database
    • iconOceanBase Cloud
    • iconOceanBase Tugraph
    • iconInteractive Tutorials
    • iconOceanBase Best Practices
    • Tools
    • iconOceanBase Cloud Platform
    • iconOceanBase Migration Service
    • iconOceanBase Developer Center
    • iconOceanBase Migration Assessment
    • iconOceanBase Admin Tool
    • iconOceanBase Loader and Dumper
    • iconOceanBase Deployer
    • iconKubernetes operator for OceanBase
    • iconOceanBase Diagnostic Tool
    • iconOceanBase Binlog Service
    • Connectors and Middleware
    • iconOceanBase Database Proxy
    • iconEmbedded SQL in C for OceanBase
    • iconOceanBase Call Interface
    • iconOceanBase Connector/C
    • iconOceanBase Connector/J
    • iconOceanBase Connector/ODBC
    • iconOceanBase Connector/NET
icon

OceanBase Database

SQL - V4.2.2

    Download PDF

    OceanBase logo

    The Unified Distributed Database for the AI Era.

    Follow Us
    Products
    OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
    Resources
    DocsBlogLive DemosTraining & Certification
    Company
    About OceanBaseTrust CenterLegalPartnerContact Us
    Follow Us

    © OceanBase 2026. All rights reserved

    Cloud Service AgreementPrivacy PolicySecurity
    Contact Us
    Document Feedback
    1. Documentation Center
    2. OceanBase Database
    3. SQL
    4. V4.2.2
    iconOceanBase Database
    SQL - V 4.2.2
    SQL
    KV
    • V 4.4.2
    • V 4.3.5
    • V 4.3.3
    • V 4.3.1
    • V 4.3.0
    • V 4.2.5
    • V 4.2.2
    • V 4.2.1
    • V 4.2.0
    • V 4.1.0
    • V 4.0.0
    • V 3.1.4 and earlier

    JSON_ARRAY

    Last Updated:2026-04-15 08:27:15  Updated
    share
    What is on this page
    Purpose
    Syntax
    Parameters
    Examples

    folded

    share

    Purpose

    JSON_ARRAY() calculates a series of SQL scalar expressions, converts each expression to a JSON value, and constructs a JSON array of the JSON values.

    JSON_ARRAY() allows you to set the type of the calculation result of an expression to a JSON object, a JSON array, a numeric literal, a text literal, a date, a timestamp, or NULL. This function converts numeric literals to JSON numeric values and text literals to JSON string values. Date or timestamp data contained in the generated JSON object or array is displayed as a JSON string in ISO 8601 date format.

    Syntax

    JSON_ARRAY (
                  [val [FORMAT JSON], val [FORMAT JSON] ...]
                        [ABSENT|NULL ON NULL]
                  [RETURNING JSON | CLOB| BLOB| VARCAHR2| VARCHAR2[size]]
                  [STRICT] )
    

    Parameters

    The parameters in the syntax are described as follows:

    • FORMAT JSON: specifies that the input string is a JSON text and no \" will be added the output result. This clause is optional.
    • ABSENT|NULL ON NULL: specifies how to handle NULL values. This clause is optional.
    • NULL ON NULL: specifies that the return value of the current expression is NULL.
    • ABSENT ON NULL: specifies to ignore the current expression if its calculation result is NULL.
    • RETURNING JSON | CLOB| BLOB| VARCAHR2| VARCHAR2[size]: specifies the return value type. This clause is optional.
    • STRICT: checks whether the output result is in JSON format. This clause is optional.

    Examples

    # Use a nested expression and the NULL ON NULL clause.
    obclient> SELECT JSON_ARRAY (JSON_ARRAY(1,2,3),100,'California',null NULL ON NULL) "JSON Array Example"
            FROM DUAL;
    +-----------------------------------+
    | JSON Array Example                |
    +-----------------------------------+
    | ["[1,2,3]",100,"California",null] |
    +-----------------------------------+
    1 row in set
    
    # The ABSENT ON NULL clause takes effect, and the result does not contain NULL values.
    obclient> SELECT JSON_ARRAY( JSON_ARRAY(1,2,3),100,'California', null ABSENT ON NULL) "JSON Array Example"
          FROM DUAL;
    +----------------------------------+
    | JSON Array Example               |
    +----------------------------------+
    | ["[1, 2, 3]", 100, "California"] |
    +----------------------------------+
    1 row in set
    
    # The FORMAT JSON clause takes effect. The input string of the current expression is treated as a JSON string. No \" is added to the output result.
    
    obclient> SELECT JSON_ARRAY('{"a":"a-value", "b" : "b-value"}' format json RETURNING CLOB)
        FROM DUAL;
    +--------------------------------------------------------------------+
    | JSON_ARRAY('{"A":"A-VALUE","B":"B-VALUE"}'FORMATJSONRETURNINGCLOB) |
    +--------------------------------------------------------------------+
    | [{"a": "a-value", "b": "b-value"}]                                 |
    +--------------------------------------------------------------------+
    1 row in set
    
    # The input string does not contain the FORMAT JSON clause. \" is added to the output result.
    obclient> SELECT JSON_ARRAY('{"a":"a-value", "b" : "b-value"}' RETURNING CLOB) FROM DUAL;
    +----------------------------------------------------------+
    | JSON_ARRAY('{"A":"A-VALUE","B":"B-VALUE"}'RETURNINGCLOB) |
    +----------------------------------------------------------+
    | ["{\"a\":\"a-value\", \"b\" : \"b-value\"}"]             |
    +----------------------------------------------------------+
    1 row in set
    
    # The return value type is specified as VARCHAR2.
    obclient> SELECT JSON_ARRAY('{"a":"a-value", "b" : "b-value"}' format json RETURNING VARCHAR2)
        FROM DUAL;
    +------------------------------------------------------------------------+
    | JSON_ARRAY('{"A":"A-VALUE","B":"B-VALUE"}'FORMATJSONRETURNINGVARCHAR2) |
    +------------------------------------------------------------------------+
    | [{"a": "a-value", "b": "b-value"}]                                     |
    +------------------------------------------------------------------------+
    1 row in set
    

    Previous topic

    Overview
    Last

    Next topic

    JSON_OBJECT
    Next
    What is on this page
    Purpose
    Syntax
    Parameters
    Examples