Join array of Objects
Hi ,
I have a requirement to join the array1 with array2 in the same document and fetch one column from array 2 into array1 if condition matches. I can do it by splitting the arrays and join them back again. I would like to to know if i can do it in minimal way using expression language? please help
studySiteId from array1 should match with studySiteId in array2 and get studySiteReferenceValue from array2 and put it in array1 with key value pair. if not matches put studySiteReferenceValue as null
INPUT
[
{
"Array1" : [
{
"Study": "D123",
"studySiteNumber":"123",
"studySiteId":806,
"countryCode":"BR"
},
{
"Study": "D124",
"studySiteNumber":"0820",
"studySiteId":807,
"countryCode":"BR"
}
],
"Array2" : [
{
"isRefFound":true,
"studySiteId":806,
"studySiteReferenceTypeId":100,
"studySiteReferenceValue":"0SI000000006E06",
"sourceSystemId":22,
"etlIsDeletedFlg":false
},
{
"isRefFound":true,
"studySiteId":8088,
"studySiteReferenceTypeId":100,
"studySiteReferenceValue":"0SI000000006E06",
"sourceSystemId":22,
"etlIsDeletedFlg":false
}
]
}
]
OUTPUT:
[
{
"Array1" : [
{
"Study": "D123",
"studySiteNumber":"123",
"studySiteId":806,
"countryCode":"BR",
"studySiteReferenceValue":"0SI000000006E06"
},
{
"Study": "D124",
"studySiteNumber":"0820",
"studySiteId":807,
"countryCode":"BR",
"studySiteReferenceValue":""
}
],
"Array2" : [
{
"isRefFound":true,
"studySiteId":806,
"studySiteReferenceTypeId":100,
"studySiteReferenceValue":"0SI000000006E06",
"sourceSystemId":22,
"etlIsDeletedFlg":false
},
{
"isRefFound":true,
"studySiteId":8088,
"studySiteReferenceTypeId":100,
"studySiteReferenceValue":"0SI000000006E06",
"sourceSystemId":22,
"etlIsDeletedFlg":false
}
]
}
]