2

How do I construct a JSON value with a nested JSON value as a serialized string? I tried this:

SQL>  select json { 'y' : json_serialize(json('{"hello":"world"}')) } x
      from dual;  

X
--------------------------------------------------------------------
{"y":{"hello":"world"}}

But the result I want is:

{"y":"{\"hello\":\"world\"}"}

I'm using Oracle Database 20c.

1 Answer 1

2

The JSON object constructor recognizes the output of json_serialize as serialized JSON and converts it to a JSON value when constructing the outer object. Use to_clob() instead:

select json { 'y' : to_clob(json('{"hello":"world"}')) } x
from dual;  
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.