New versions: Dev (3.16) | Latest (3.15) | 3.14 | 3.13 | 3.12

JSON predicate

Applies to ✅ Open Source Edition   ✅ Express Edition   ✅ Professional Edition   ✅ Enterprise Edition

The JSON predicate can be used to check if a given expression is valid JSON

SELECT 1
FROM dual
WHERE '{}' IS JSON
AND '{' IS NOT JSON
create.selectOne()
      .where(val("{}").isJson())
      .and(val("{").isNotJson())
      .fetch();

Dialect support

This example using jOOQ:

val("{}").isJson()

Translates to the following dialect specific expressions:

-- MYSQL
json_valid('{}')

-- ORACLE
'{}' IS JSON

-- SQLSERVER
(isjson('{}') = 1)

-- ACCESS, ASE, AURORA_MYSQL, AURORA_POSTGRES, BIGQUERY, COCKROACHDB, DB2, DERBY, EXASOL, FIREBIRD, H2, HANA, HSQLDB, 
-- INFORMIX, MARIADB, MEMSQL, POSTGRES, REDSHIFT, SNOWFLAKE, SQLDATAWAREHOUSE, SQLITE, SYBASE, TERADATA, VERTICA, YUGABYTE
/* UNSUPPORTED */

(These are currently generated with jOOQ 3.16, see #10141), or translate your own on our website

Feedback

Do you have any feedback about this page? We'd love to hear it!

The jOOQ Logo