Search notes:

ORA-40587: invalid JSON type

The following select statement produces an ORA-40587: invalid JSON type error.
select json_object_t('{"num": 42, "txt": "hello world"}') from dual;
However, this PL/SQL block runs fine:
declare
   j json_object_t;
begin
   j := json_object_t('{"num": 42, "txt": "hello world"}');
end;
/
My assumption (!) is that this error is thrown in SQL because json_object_t is not a persistable type.

Oracle considers scalar values not valid JSON

Oracle considers scalar values to be invalid JSON, the following PL/SQL block throws error ORA-40573:
declare
   obj json_element_t;
begin
   obj := json_element_t.parse(42);
end;
/
These two blocks don't throw the error:
declare
   obj json_element_t;
begin
   obj := json_element_t.parse('{"num": 42}');
end;
/
 
declare
   obj json_element_t;
begin
   obj := json_element_t.parse('[1,2,3]');
end;
/

See also

ORA-40573: invalid use of PL/SQL JSON object type
JSON related PL/SQL object types
Other Oracle error messages

Index