2

In Oracle 21c, it looks like we can return a resultset as JSON text:

SELECT json_object(*)
from dual;

result:
{"DUMMY":"X"}

That works in db<>fiddle:

enter image description here

Question:

Is there a way to return the JSON text using pretty formatting?

{
   "DUMMY":"X"
}

Related: Select JSON text of SDO_GEOMETRY using SQL

1 Answer 1

5

As documented, you can add PRETTY to a JSON function to prettify it

SELECT json_object(* PRETTY)
from dual;

db<>fiddle

Output

{
  "DUMMY" : "X"
}

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.