Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Oracle.ORDS: How to return column as a JSON array?

I have a master table and a detail table.
I want to make a "GET" request to get something like this

select "id","name","color","etc",
(select json_arrayagg(regions returning clob) from tbl_regions r where r.id = t.id) regions from clients t;

and i want to have a json array in the result JSON.
BUT I have a string attribute in a reponse from ORDS service.
How to convert or to set type to a json array to a column

now i have a relust like this

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

{
..
..
..
"regions":"["1","2"]"
}

but i want a natural array without ‘"’

"regions":["1","2"]

>Solution :

JSON results from ORDS should be aliased "{}some_name".
Without the braces the engine converts the result into an escaped string.
And I would return json_object per row, it could be easier for the client instead of the mix you are trying to do.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading