+ 1

Get JSON Array of Objects using SQL

I've been trying to get Array of Objects, but all I'm ending up getting only Objects. Below is the sample Oracle query written. 't1' data is mapped from already created data. SELECT t1.REQID AS "requestDetail.reqId", t1.PRIMARY_KEYS AS "requestDetail.pk", t1.ENTITY_NAME AS "requestDetail.entityName", t1.STATUS AS "requestDetail.stage, t2.id AS "id", t2.div AS "div", t2.code AS "group.code", t2.type AS "group.type", t2.task1 AS "group.animalGroup.task1", t2.task2 AS "group.animalGroup.task2" FROM FLOW_REQUEST t1 JOIN json_table(t1.REQ_MESSAGE,'$.animals' columns( id PATH '$.id', div PATH '$.div', NESTED PATH '$.group[*]' COLUMNS ( code PATH '$.group.code', type PATH '$.group.type', task1 PATH '$.group.animalGroup.task1', task2 PATH '$.group.animalGroup.task2' ))) t2 ON t1.PRIMARY_KEYS = t2.id WHERE t1.ENTITY_NAME ='ANIMALS' AND t1.STATUS ='DRAFT' Here's the JSON Response I'm getting the "Group" as an Object. {"animals": [{ "id": "1", "requestDetail": { "reqId": "1", "pk": "1", "entityName": "ANIMALS", "status": "ACTIVE" }, "type": "animal", "group": {"code": "A1", "animalGroup": { "task1": "eats", "task2": "sleep" } } }] } Expected "Group" to be an Array (like below) {"animals": [{ "id": "1", "requestDetail": { "reqId": "1", "pk": "1", "entityName": "ANIMALS", "status": "ACTIVE" }, "type": "animal", "group": [{"code": "A1", "animalGroup": { "task1": "eats", "task2": "sleep" } }] }] }

14th Oct 2020, 3:54 PM
Prithvi
2 Answers
+ 1
What exactly do you need help with
31st Oct 2020, 8:23 PM
Izaiah Kay
Izaiah Kay - avatar
0
Need JSON Array of Objects. All I'm ending up getting is only Objects
31st Oct 2020, 8:41 PM
Prithvi