【发布时间】:2018-12-19 08:36:58
【问题描述】:
我有一个 json 有效负载,我需要在转换消息中使用过滤器过滤掉十进制值 0.00。 请找到转换消息:
%dw 1.0
%output application/java
---
payload map ((currentOptyLineItem , currentOptyLineItemIndex) -> {
OpportunityId: currentOptyLineItem.OPPORTUNITYID,
PricebookEntryId: currentOptyLineItem.PRICEBOOKENTRYID,
Mix__c: currentOptyLineItem.MIX__C ,
Product_Family__c: currentOptyLineItem.PRODUCT_FAMILY__C,
QuoteId__c: currentOptyLineItem.QUOTEID__C as :string,
Extended_Net_Price__c: currentOptyLineItem.EXTENDED_NET_PRICE__C,
Recurring_Percentage__c: currentOptyLineItem.RECURRING_PERCENTAGE,
Term__c : currentOptyLineItem.TERM,
Product_Family_Service_Level_Recurring__c: currentOptyLineItem.ROFLAG,
Product_with_Product_Family__c : currentOptyLineItem.BUSINESS_ENTITY__C as :string ++ "-" ++ currentOptyLineItem.SUB_BUSINESS_ENTITY__C as :string ++ "-" ++ currentOptyLineItem.PRODUCT_FAMILY__C
} filter currentOptyLineItem.MIX__C > 0
)
但我收到错误消息:
根异常堆栈跟踪: com.mulesoft.weave.mule.exception.WeaveExecutionException:异常 执行时:payload.Product_with_Product_Family__c 映射 ((referenceKey , index) -> "'" ++ referenceKey ++ "'") reduce ($$ ++ "," ++ $) ^ 'map' 运算符的类型不匹配 找到 :null, :function required :array, :function.
【问题讨论】:
-
包含示例有效负载将是最有帮助的。
-
请细化样本负载:
-
{ "name": "xxx", "beInfo": [ { "name": "Collaboration", "subBeInfo": [ { "name": "yyy", "roDetails": [ { "roFlag": "N", "termInfo": [{ "extNetPrice": 95398.85, "term": 12 }] } ] } ] } ] },
-
嗨,您指定的输入与您的脚本不匹配的两件事,也不是错误。现在根据错误消息,您的 mule 代码中的某处似乎有一个表达式
payload.Product_with_Product_Family__c map ...并且 Product_withProduct_Family__c 为 null 您可以使用payload.Product_with_Product_Family__c default [] map ...轻松解决此问题 -
如上文所述,请提供正确的输入负载。虽然你可以试试这个。