在Mule/Dataweave中,如何將HashMap轉換/轉換爲數組。我有一個HashMap,其關鍵字&是動態數字。Mule/Dataweave在Mule/Dataweave中,如何將HashMap轉換爲數組
實施例:
{"3.2" : 1, "22" : 8, "2.0" : 1}
我想將它轉換到這樣的結構:
[
{
"name": "app-a",
"value1": 3.2,
"value2": 1
},
{
"name": "app-a",
"value1": 22,
"value2": 8
},
{
"name": "app-a",
"value1": 2,
"value2": 1
}
]
溶液(由於@Sulthony 1H)
%dw 1.0
%output application/json
---
payload pluck $$ map {
value1: ($ as :string) as :number,
value2: payload[$]
}
太棒了。完美解決方案我也用實際的編織代碼進行了更新。 – gnanagurus