如何使用dataweave mule从地图中删除特定字段

时间:2018-02-01 06:44:11

标签: mule mule-studio mule-component mule-el mule-esb

如何使用dataweave从地图中删除特定字段

输入:

{ 答:1, B:2, C:3, d:4 }

我想删除c和d字段(c和d值是动态的)并仅显示 输出

{ 答:1, B:2- }

我们如何在数据编织中完成

2 个答案:

答案 0 :(得分:1)

根据Dataweave Reference Documentation,您可以从对象中删除字段。试试这个:



%dw 1.0
%output application/json
---
payload - "c" - "d"




答案 1 :(得分:1)

以下代码可以正常工作:

%dw 2.0
var arr=["c","d"]
output application/json
---
payload filterObject ((value, key, index) -> !(arr contains  (key) as String))

您可以在变量'arr'中添加/删除要排除的键。