I have many JSON objects where I need to match a field to process them together.
In the JSON below, you can see two objects. The two objects can repeat, but don’t have to. I need to:
- Get the objects where the serial number matches
- Add them both to an object
- Repeat for all the other objects
- Send the whole thing to a subflow
I’m not married to the format. I gladly take suggestions on a better way. For context, I’m pulling assets from HaloPSA and Hudu, matching on serial in a merge node. These are snippets from the output of the merge node.
Thank you in advance!
No error. I don’t see a node that would seem to do this.
Where I’m at:
[
{
"halopsa": {
"id": 40,
"inventory_number": "MBA PDX M2",
"key_field": "MBA PDX M2",
"key_field2": "Serial1",
"key_field3": "c4:35:d9:7a:d7:00",
"client_id": 20
},
"hudu": {
"id": 4432,
"company_id": 5,
"asset_layout_id": 30,
"slug": "mac-gjg4jrkfxh-c990dee3d24f",
"name": "MBA PDX M2",
"primary_serial": "Serial1",
"primary_mail": "",
"primary_model": "MacBook Air (M2, 2022)",
"primary_manufacturer": "Apple, Inc"
}
},
{
"halopsa": {
"id": 41,
"inventory_number": "MBA PDX M1",
"key_field": "MBA PDX M1",
"key_field2": "Serial2",
"key_field3": "c0:95:6d:2f:9c:fe",
"client_id": 20
},
"hudu": {
"id": 5547,
"company_id": 5,
"asset_layout_id": 30,
"slug": "mba-pdx-m1-68ae9bb709c9",
"name": "MBA PDX M1",
"primary_serial": "Serial2",
"primary_mail": null,
"primary_model": "MacBook Air (M1, 2020)",
"primary_manufacturer": "Apple, Inc"
}
}
]
Where I would like to be:
[
{
"asset": {
"halopsa": {
"id": 40,
"inventory_number": "MBA PDX M2",
"key_field": "MBA PDX M2",
"key_field2": "Serial1",
"key_field3": "c4:35:d9:7a:d7:00",
"client_id": 20
},
"hudu": {
"id": 4432,
"company_id": 5,
"asset_layout_id": 30,
"slug": "mac-gjg4jrkfxh-c990dee3d24f",
"name": "MBA PDX M2",
"primary_serial": "Serial1",
"primary_mail": "",
"primary_model": "MacBook Air (M2, 2022)",
"primary_manufacturer": "Apple, Inc"
}
}
},
{
"asset": {
"halopsa": {
"id": 41,
"inventory_number": "MBA PDX M1",
"key_field": "MBA PDX M1",
"key_field2": "Serial2",
"key_field3": "c0:95:6d:2f:9c:fe",
"client_id": 20
},
"hudu": {
"id": 5547,
"company_id": 5,
"asset_layout_id": 30,
"slug": "mba-pdx-m1-68ae9bb709c9",
"name": "MBA PDX M1",
"primary_serial": "Serial2",
"primary_mail": null,
"primary_model": "MacBook Air (M1, 2020)",
"primary_manufacturer": "Apple, Inc"
}
}
}
]
Information on your n8n setup
- n8n version: 1.38.2
- Database (default: SQLite): PostgresQL
- n8n EXECUTIONS_PROCESS setting (default: own, main):
- Running n8n via (Docker, npm, n8n cloud, desktop app): Docker on DO
- Operating system: Ubuntu 22.04.3 LTS