I am getting a JSON response from an API GET request into my Mule flow which looks somewhat like the below JSON. I am trying to map this to achieve an output list where each customer looks somewhat like below. problem is the company card number which sits under custom attributes and also I keep getting the error show at the bottom. I have tried to use the payload map (value,key) function which is giving me that error. When I use pluck I get all items listed under id, firstname etc but I want them individually soa repeated list.
Thank you!
{
"items": [
{
"id": 17837,
"group_id": 2,
"email": "[email protected]",
"firstname": "Catherine5",
"lastname": "Brugge",
"custom_attributes": [
{
"attribute_code": "customer_id",
"value": "29a8-303b-01c7fe28"
}
]
},
{
"id": 17839,
"group_id": 2,
"email": "[email protected]",
"firstname": "Catherine",
"lastname": "Brugge",
"website_id": 2,
"addresses": [
{
"id": 33773,
"customer_id": 17839,
"region": {
"region_code": null,
},
"region_id": 0,
"street": [
"123 Kings Road"
],
"default_billing": true
}
],
"disable_auto_group_change": 0,
"custom_attributes": [
{
"attribute_code": "company_card_number",
"value": "100000000"
},
{
"attribute_code": "ustomer_id",
"value": "29a8-c3443e-014062"
}
]
},
{
"id": 18357,
"group_id": 2,
"email": "[email protected]",
"firstname": "Catherine",
"lastname": "Brugge",
"custom_attributes": [
{
"attribute_code": "company_card_number",
"value": "888243"
},
{
"attribute_code": "customer_id",
"value": "2b02-88583c-021559"
}
]
}
],
"search_criteria": {
"filter_groups": [
{
"filters": [
{
"field": "group_id",
"value": "2",
"condition_type": "equal"
}
]
}
]
},
"total_count": 3
}
You called the function 'map' with these arguments:
1: Object ({items: [{id: ...)
2: Function ((value:Any, key:Any) -> ???)
{
"customers":{
"id": payload.items.id,
"group_id": payload.items.group_id,
"firstname":payload.firstname,
"lastname": payload.lastname,
"email": payload.email,
"company_card_number": ???
}
}