Reputation: 692
I am using the "retrieve all" object store component and I get back a java payload like this:
{
{
target: "test-app-387562893"
}
}
which is a LinkedHashMap with the entries.
I need to convert this to an Array of objects i.e.
[
{
target: "test-app-387562893"
}
]
I have tried using pluck
to map the entries into an array.
input: Original LinkedHashMap payload
%dw 2.0
output application/java
---
payload pluck (value,key) -> {
(key): value
}
output: Array with LinkedHashMap
However that just adds the entire LinkedHashMap as an item in the array.
Is there another way to get LinkedHashMap entries into objects in an array?
Upvotes: 1
Views: 1096
Reputation: 692
Should have looked further into this area of the DW documentation.
Looks like dw::core::Objects::entrySet(payload)
will convert it to an array of objects.
Incidentally as soon as I ran the original payload through a Foreach scope (which is why I needed an Array of Objects) to see the error it generated the error message recommended using the entrySet
function as well. Kudos to the dw and studio engineers for that.
Upvotes: 2