在sql/JSON(Oracle数据库)中构造嵌套的JSON值
如何将嵌套的JSON值作为序列化字符串来构造JSON值?我试过这个:在sql/JSON(Oracle数据库)中构造嵌套的JSON值,sql,json,database,oracle,serialization,Sql,Json,Database,Oracle,Serialization,如何将嵌套的JSON值作为序列化字符串来构造JSON值?我试过这个: SQL> select json { 'y' : json_serialize(json('{"hello":"world"}')) } x from dual; X -------------------------------------------------------------------- {"y":{"hello&q
SQL> select json { 'y' : json_serialize(json('{"hello":"world"}')) } x
from dual;
X
--------------------------------------------------------------------
{"y":{"hello":"world"}}
但我想要的结果是:
{"y":"{\"hello\":\"world\"}"}
我使用的是Oracle数据库20c。对象构造函数将
JSON\u serialize
的输出识别为序列化JSON,并在构造外部对象时将其转换为JSON值。改为使用来\u clob()
:
select json { 'y' : to_clob(json('{"hello":"world"}')) } x
from dual;