I have a query related to merging two different objects from the database, both in JSON format.
These two objects share two key/value pairs: IRBId = ...
and id = ...
, which can be seen in the examples below:
OBJ 1
{
"data":{
"IRBs":{
"nodes":[
{
"id":"8",
"name":"Admin",
},
{
"id":"9",
"name":"Again",
}
]
}
}
}
OBJ 2
{
"data":{
"informedConsentForms":{
"count":3,
"nodes":[
{
"id":"93",
...
"IRBId":"9",
},
{
"id":"92",
...
"IRBId":"8",
},
{
"id":"91",
...
"IRBId":"8",
}
]
}
}
It is evident that OBJ 2 and OBJ 1 correspond with each other based on the matching IRBid and id values.
The desired outcome is to merge these two objects where IRBId OBJ 2 === id OBJ 1
.
The expected result after the merge would look like this:
Merged OBJ
{
[{
"id":"93",
...
"IRBId":"9",
"irb": {
"name":"Again",
...
}
},
{
"id":"92",
...
"IRBId":"8",
"irb": {
"name":"Admin",
...
}
},
{
"id":"91",
...
"IRBId":"8",
"irb": {
"name":"Admin",
...
}
]
}
I am unsure how to achieve this specific formatting. Please assist.