Skip to Main Content

Oracle Database Free

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Bug: Wrong result when using json_serialize with pretty and ordered option

Philipp SalvisbergJul 14 2026 — edited Jul 14 2026

When I run the following query in an Oracle Database 26.2.0

select json_serialize(
          json(
             '{
                "xyz": [],
                "configs": [],
                "z": 1,
                "a": 2
             }'
          )
          returning clob
          ordered
       );

I get this correctly ordered result:

{"a":2,"configs":[],"xyz":[],"z":1}

When I add the pretty option to the json_serialize function, the result is pretty printed, but the order of the object members is wrong. Here's the query:

select json_serialize(
          json(
             '{
                "xyz": [],
                "configs": [],
                "z": 1,
                "a": 2
             }'
          )
          returning clob
          pretty
          ordered
       );

and the wrong result:

{                                                                               
  "a" : 2,                                                                      
  "z" : 1,                                                                      
  "configs" :                                                                   
  [                                                                             
  ],                                                                            
  "xyz" :                                                                       
  [                                                                             
  ]                                                                             
}   

I get the same result in Autonomous Database with version 23.26.3.1.0.

I would expect the following as in the result without the pretty option.

{
  "a" : 2,
  "configs" :
  [
  ],
  "xyz" :
  [
  ],
  "z" : 1
}

IMO this is a bug since the documentation says that you combine ordered with pretty.

This post has been answered by Chris Saxon-Oracle on Jul 31 2026
Jump to Answer
Comments
Post Details
Added on Jul 14 2026
12 comments
228 views