Skip to Main Content

ORDS, SODA & JSON in the Database

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!

Return Json data stored in a col

Mike286Feb 9 2016 — edited Mar 2 2016

Hi,

Mine is Oracle 12c plus ORDS 3

I have a table (my_test) with two col, one col is project_no, another is a p_definition, an Json col that will store the actual json data.

I have create a web service where I want to return the data stored in the p_definition as JSON data, I am using the sql

select JSON_QUERY(p_definition,'$') as definition from my_test to provide the web service and here is what I got, as you can see, the actual json data is returned as a col(definition)

{

- items:

   [

    • {
      • definition: "{"BuildSequence":["ServerBuild","DBBuild"],"DataBase":[{"SID":""}],"Environment":{"DC":"XXX","Environment":"Stage"},"Project_No":"30","Servers":[{"Application":"app1.1","Hostname":"","size":"small"}]}"
    • }
    • {
    •              definition: "{"BuildSequence":["ServerBuild","DBBuild"],"DataBase":[{"SID":""}],"Environment":{"DC":"YYY","Environment":"Prod"},"Project_No":"24","Servers":[{"Application":"app1.1","Hostname":"","size":"small"}]}"
    • }

       ]

}



What I wanted is something like this, eg, I wanted the json data return as json, not data in a col.


{

-items:[

     { "BuildSequence":[ "ServerBuild","DBBuild"],

       "DataBase":[ { "SID":""}],   

       "Environment":{ "DC":"XXX","Environment":"Stage"},

       "Project_NO":"30",

       "Servers":[ { "Application":"app1.1","Hostname":"","size":"small"}]

     }

     { "BuildSequence":[ "ServerBuild","DBBuild"],

       "DataBase":[ { "SID":""}],   

       "Environment":{ "DC":"YYY","Environment":"Stage"},

       "Project_NO":"30",

       "Servers":[ { "Application":"app1.1","Hostname":"","size":"small"}]

     }

           ]

}


Is this possible?


Thanks


Mike

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 30 2016
Added on Feb 9 2016
4 comments
1,154 views