… Is Json [Array|Object|Scalar]

Test for Valid JSON, Distinguish between Arrays, Objects and Scalars


BigQueryDb2 (LUW)DerbyH2MariaDBMySQLOracle DBPostgreSQLSQL ServerSQLite20092011201320152017201920212023⊘ 3.9.1 - 3.50.0c⊘ 3.5.7 - 3.8.11⊘ 2008R2 - 2022✓ 16 - 17⊘ 8.3 - 15⚠ 21c - 23.9a⚡ 12cR2 - 19cd⚡ 12cR1ab⊘ 11gR1 - 11gR2⊘ 5.7 - 9.4.0c⊘ 5.0 - 5.6⊘ 10.2 - 12.0.2c⊘ 5.1 - 10.1✓ 1.4.200 - 2.3.232⊘ 1.4.192 - 1.4.199⊘ 10.15.1.3 - 10.17.1.0⊘ 9.7 - 12.1.2⊘ 2.0c
  1. ⚡Does not recognize JSON scalars as valid JSON
  2. No type constraints: … is json [array|object|scalar]
  3. See Alternatives
  4. Accepts unquoted object keys: {a: 1}

Is json is a predicate, similar to is null, to test something for valid JSON content. The test can also distinguish between Arrays ([1,42]), Objects ({"a":42}) and scalar values (strings, numbers, true, false, null).

WHERE c IS JSON OBJECT

The example picks rows for which the column c contains a valid JSON structure of which the topmost element is a JSON object.

As is json never fails it can be used to test the contents of string values for well-formed JSON contents. If the input is the SQL null value, the result is also the SQL null (unknown) value.

The type constraints array, object and scalar make it even useful for values of the type JSON. If no type constraint is specified, value is implied—which returns true for all valid JSON data.

BigQuery 2025-09-02Db2 (LUW) 12.1.2Derby 10.17.1.0H2 2.3.232MariaDB 12.0.2MySQL 9.4.0Oracle DB 23.9aabbbPostgreSQL 17SQL Server 2022SQLite 3.50.0… is json       … is json value … is json array … is json object… is json scalar
  1. Accepts unquoted object keys: {a: 1}
  2. Not for character strings

Is json does not allow to check for the specific scalar types string, numeric, boolean or the null values (the SQL/JSON Path item method .type() supports that).

Negation can be done with is not json. Here it has to be noted that is not json object returns true for non-JSON data as well as for valid JSON data that does not have an object at the top level.

Formats and Dialects

SQL uses the JSON format defined by IETF RFC 8259. This JSON format allows a single JSON object to contain the very same key value multiple times:0

{"a": 42,
 "a": 1}

Therefore, the is json predicate accepts such objects as valid JSON. For environments that require a more rigid validation the standard provides the with unique [key] option that causes is json to treat objects with duplicate keys as invalid JSON.

BigQuery 2025-09-02Db2 (LUW) 12.1.2Derby 10.17.1.0H2 2.3.232MariaDB 12.0.2MySQL 9.4.0Oracle DB 23.9PostgreSQL 17SQL Server 2022SQLite 3.50.0is json [without unique [keys]]is json  with    unique [keys] 

Further, the SQL standard defines a syntax to specify another data format such as BSON or AVRO by postfixing the tested expression with the format clause. In absence of a format clause format json is implied with refers to the the RFC 8259 format.

BigQuery 2025-09-02Db2 (LUW) 12.1.2Derby 10.17.1.0H2 2.3.232bMariaDB 12.0.2MySQL 9.4.0Oracle DB 23.9aPostgreSQL 17SQL Server 2022SQLite 3.50.0… is json… format json is json
  1. Accepts unquoted object keys: {a: 1}
  2. Fails on non-json input

The SQL standard defines only one format: json. Other formats and their names are implementation-defined (IV180).

Alternatives

BigQuery 2025-09-02Db2 (LUW) 12.1.2Derby 10.17.1.0H2 2.3.232MariaDB 12.0.2MySQL 9.4.0Oracle DB 23.9PostgreSQL 17SQL Server 2022SQLite 3.50.0isjson(…, <type constraint>) = 1json_valid(…) = 1safe.parse_json(…) is not null
Optional Features
Alternatives
Implementation-Defined Items
  • IV180,“The data format specified by <implementation-defined JSON representation option>”

Tutorials

Normative References

The <JSON predicate> is [not] json [value|array|object|scalar] is defined in ISO/IEC 9075-2:2023 as part as the optional feature T821, “Basic SQL/JSON query operators”.

You can’t catch up on 20 years of SQL evolution in one day. Subscribe the newsletter via E-Mail, Bluesky or RSS to gradually catch up and to keep modern-⁠sql.com on your radar.

About the Author

Photo of Markus Winand

Markus Winand provides insights into SQL and shows how different systems support it at modern-sql.com. Previously he made use-the-index-luke.com, which is still actively maintained. Markus can be hired as trainer, speaker and consultant via winand.at.

Buy the Book

Cover of “SQL Performance Explained”: Squirrel running on grass

The essence of SQL tuning in 200 pages

Buy now!
(paperback and/or PDF)

Paperback also available at Amazon.com.

Hire Markus

Markus offers SQL training and consulting for developers working at companies of all sizes.
Learn more »

Footnotes

  1. ISO/IEC 9075-2:2023 §4.48 (NOTE 111)

Connect with Markus Winand

Subscribe mailinglistsSubscribe the RSS feedMarkus Winand on LinkedInMarkus Winand on XINGMarkus Winand on TwitterMarkus Winand on Bluesky
Copyright 2015-2025 Markus Winand. All righs reserved.
Legal | Contact | NO WARRANTY | Trademarks | Privacy and GDPR