2.3 Oracle Database Support for JSON

Oracle Database support for JavaScript Object Notation (JSON) is designed to provide the best fit between the worlds of relational storage and querying JSON data, allowing relational and JSON queries to work well together. Oracle SQL/JSON support is closely aligned with the JSON support in the SQL Standard.

Oracle Database supports the JSON format as specified in ECMAScript edition 5.1.

See Also:

2.3.1 Support for RFC 8259: JSON Scalars

Starting with Release 21c, Oracle Database supports IETF RFC 8259, which allows a JSON document to contain a JSON scalar value, instead of just an object or array, at top level. This support also means that functions that return JSON data can return scalar JSON values.

For this support, database initialization parameter compatible must be 20 or greater.

In database releases prior to 21c only IETF RFC 4627 was supported, which allows only a JSON object or array, not a scalar, at the top level of a JSON document. RFC 8259 support includes RFC 4627 support (and RFC 7159 support).

If parameter compatible is 20 or greater then JSON data, regardless of how it is stored (as JSON type or textually), supports RFC 8259 by default. But for a given JSON column you can use an is json check constraint to exclude the insertion of documents there that have top-level JSON scalars (that is, support only RFC 4627, not RFC 8259), by specifying the new is json keywords DISALLOW SCALARS.

With parameter compatible 20 or greater you can also use keywords DISALLOW SCALARS with SQL/JSON function json_query (or with a json_table column that has json_query semantics) to specify that the return value must be a JSON object or array. Without these keywords a JSON scalar can be returned.

If parameter compatible is 20 or greater you can also use SQL data type JSON, its constructor JSON, and SQL/JSON function json_scalar. If compatible is less than 20 then an error is raised when you try to use them.

If compatible is 20 or greater you can nevertheless restrict some JSON data to not allow top-level scalars, by using keywords DISALLOW SCALARS. For example, you can use an is json check constraint with DISALLOW SCALARS to prevent the insertion of documents that have a top-level scalar JSON value.

WARNING:

If you change the value of parameter compatible to 20 or greater then you cannot later return it to a lower value.