Hi All,
I want to combine multiple rows in a single JSON_OBJECT but I am not able to find a direct way, is it possible to achieve it using SQL?
Here is my test script
create table test_tbl(id number, name varchar2(1000));
insert into test_tbl values(1, 'Test1');
insert into test_tbl values(2,'Test2');
select json_object('Data' VALUE json_arrayagg(
json_object(name value to_char(id))
))
from test_tbl;
The JSON output received as a result is
{
"Data": [{
"Test1": "1"
},
{
"Test2": "2"
}
]
}
And the JSON which I need is the following
{
"Data": {
"Test1": "1",
"Test2": "2"
}
}
Can someone suggest whether this is possible to achieve using JSON functions of SQL?