cancel
Showing results for 
Search instead for 
Did you mean: 

Array of Objects manipulation

lake
New Contributor

Hi team,

I would like to iterate thru an array of objects and verify if the objects has same num, code and date with different boxNumbers, then I should add the boxNumbers together and make that as a single object. If those three didn't match I should leave the object as is. Could you please help me on this?
Sample Input data:
[
{
"product": [
{
"num": "69315013901",
"code": "C06024",
"date": "2026-03-31",
"boxNumber": [
"453215578875",
"964070610419"
]
},
{
"num": "69315013901",
"code": "C06024",
"date": "2026-03-31",
"boxNumber": [
"153720699865",
"547398527901",
"994797055803"
]
},
{
"num": "69315030805",
"code": "083L022",
"date": "2025-11-30",
"boxNumber": [
"VUANJ6KYSNB",
"DPPG4NWK695"
]
}
]
}
]

Expected Output:

[
{
"product": [
{
"num": "69315013901",
"code": "C06024",
"date": "2026-03-31",
"boxNumber": [
"453215578875",
"964070610419",
"153720699865",
"547398527901",
"994797055803"
]
},
{
"num": "69315030805",
"code": "083L022",
"date": "2025-11-30",
"boxNumber": [
"VUANJ6KYSNB",
"DPPG4NWK695"
]
}
]
}
]

3 REPLIES 3

Aleksandar_A
Contributor III

Hello @lake,

Attached is the sample pipeline for structuring the data as needed:

  1. Split the ndc array.
  2. Sort and group by num, lotNum, and expDate.
  3. Consolidate serialNumber.
  4. Reassemble the ndc array.

Aleksandar_A_0-1723621229621.png

 

Let me know if you have any questions.

Best regards,

Aleksandar.

Hi Aleksandar,

Thank you so much. I would like to know where are you checking the equivalence of num, lotNumber and expDate of first ndc object with the next ndc object? 

Hello,

The functionality of the Group By Fields Snap does that. It groups the documents by the value of fields.

Regards,

Aleksandar.