I know reduce is the function I need to use but I don’t know how to start. I want to group questions with the same sectionID
. How can I manipulate this object?
[
{
"processUrlID": "9a0e6b48-4019-46ff-9513-eff55c8a0716",
"processParent": "84050058-534d-4e60-92e6-95315786e360",
"questions": [
{
"processTitle": "sdqf",
"processType": "Question",
__"DATAINS_TXTSIN_checklistSection": "sqd",
"DATAINS_TXTSIN_checklistSectionID": "2d9c7bc3-c6f7-4204-a174-1fad80f206a7",__
"DATAINS_TXTMUL_Info": null,
"DATAINS_TXTSIN_choices": null,
"DATAINS_TXTSIN_ResponseType": "YNA",
"DATAINS_TXTSIN_language": null,
"DATAINS_TXTSIN_checklistParent": null,
__"processUrlID": "da65e3aa-def0-4b69-bbca-7b0c3fe44572",__
"processParent": "9a0e6b48-4019-46ff-9513-eff55c8a0716",
"dateModified": "2022-04-15T08:38:58.302Z"
},
{
"processTitle": "qsdf",
"processType": "Question",
__"DATAINS_TXTSIN_checklistSection": "sqd",
"DATAINS_TXTSIN_checklistSectionID": "2d9c7bc3-c6f7-4204-a174-1fad80f206a7",__
"DATAINS_TXTMUL_Info": null,
"DATAINS_TXTSIN_choices": null,
"DATAINS_TXTSIN_ResponseType": "YNA",
"DATAINS_TXTSIN_language": null,
"DATAINS_TXTSIN_checklistParent": null,
__"processUrlID": "0cca5b1d-d5d8-4d5b-9f4c-9cb6ff92e4c6",__
"processParent": "9a0e6b48-4019-46ff-9513-eff55c8a0716",
"dateModified": "2022-04-15T08:39:02.028Z"
},
{
"processTitle": "qsdfsf",
"processType": "Question",
__"DATAINS_TXTSIN_checklistSection": "eazr",
"DATAINS_TXTSIN_checklistSectionID": "a4bbde66-8ba0-4513-a64d-41fc34c7827c",__
"DATAINS_TXTMUL_Info": null,
"DATAINS_TXTSIN_choices": null,
"DATAINS_TXTSIN_ResponseType": "NOKNA",
"DATAINS_TXTSIN_language": null,
"DATAINS_TXTSIN_checklistParent": null,
__"processUrlID": "d2e70fc8-990b-4660-9d62-1ca0df0d64d3",__
"processParent": "9a0e6b48-4019-46ff-9513-eff55c8a0716",
"dateModified": "2022-04-15T08:45:37.973Z"
}
],
"sections": [
{
__"processUrlId": "2d9c7bc3-c6f7-4204-a174-1fad80f206a7",__
"processParent": "84050058-534d-4e60-92e6-95315786e360",
"name": "sqd",
"language": null,
"isDirty": true,
"dateModified": "2022-04-15T08:38:57.211Z"
},
{
__"processUrlId": "a4bbde66-8ba0-4513-a64d-41fc34c7827c",__
"processParent": "84050058-534d-4e60-92e6-95315786e360",
"name": "eazr",
"language": null,
"isDirty": false,
"dateModified": "2022-04-15T08:45:36.103Z"
}
]
}
]
to become this object:
[
{
"section": "Section 1",
"sectionID": "95f5c4c0-e66b-4bff-bdb1-63e5278bf71c",
"questions": [
"61d8bbbe-2105-4a23-b635-365fc63cca2a",
"f0ba38ff-f6c5-44f5-b805-e3adff1706e6",
"38ab4c01-f5bf-4da5-a350-861ff7697d7c",
"2d35a051-833f-44f8-a94c-d386fb49aff5"
]
},
{
"section": "Section 2",
"sectionID": "351741fc-3ce0-4a01-885c-7815a73cae52",
"questions": [
"24889d1a-98e9-4107-8d69-d6681b03953f"
]
}
]