Search code examples
sqljsonoracle-databaseoracle19c

Oracle JSON_OBJECT how to have a missing key


I am looking for how to create an empty object in JSON with Oracle JSON functions

I have data I am trying to build that looks like this.

{}

The data in the middle gets filled in from many individual functions.

I have tried things like this.

SELECT JSON_OBJECT(key 'test' VALUE null) from dual ; -- this works like you expect
SELECT JSON_OBJECT(VALUE null) from dual ; -- this gives an error ORA-02000: missing VALUE keyword

I'm running Oracle 19c.


Solution

  • Call JSON_OBJECT() with no arguments.

    SELECT JSON_OBJECT() FROM DUAL;
    

    DEMO