【发布时间】:2021-02-16 17:49:54
【问题描述】:
我收到来自 API GET 请求的 JSON 响应到我的 Mule 流中,它看起来有点像下面的 JSON。我试图映射它以实现每个客户看起来有点像下面的输出列表。问题是位于自定义属性下的公司卡号,而且我一直在底部显示错误。我试图使用给我这个错误的有效载荷映射(值,键)函数。当我使用 pluck 时,我会在 id、firstname 等下列出所有项目,但我希望它们单独出现重复列表。
谢谢!
{
"items": [
{
"id": 17837,
"group_id": 2,
"email": "catherinebrugge@tprg.com",
"firstname": "Catherine5",
"lastname": "Brugge",
"custom_attributes": [
{
"attribute_code": "customer_id",
"value": "29a8-303b-01c7fe28"
}
]
},
{
"id": 17839,
"group_id": 2,
"email": "catherineb@123.com",
"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": "catherinebrugge@543.com",
"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": ???
}
}
【问题讨论】:
-
你好凯瑟琳,请告诉我们这里想要的输出是什么?所以我们可以帮助您改变这一点
-
请同时添加完整的当前 DataWeave 脚本和完整的错误消息。