Are you trying to collect them into a single data structure, or just
iterate over the key/value pairs? For the former, you'd need to change
the key names somehow, since each object in the array has the same
keys. For the latter, you can use each() to iterate over any
collection:
mylist.each {arrayEntry -> arrayEntry.each {k,v -> println "$k = $v"}}
Note that the each() for a Map allows you to get the key and value
separately in the closure, rather than iterating over Map.Entry
objects and having to call it.key and it.value.
Regards,
Matt
On Wed, Sep 5, 2018 at 9:27 AM l vic <[email protected]> wrote:
>
> I have json array attribute:
> mylist
> :[{"id":10,"info":"2am-3am"},{"id":11,"info":"3AM-4AM"},{"id":12,"info":"4am-5am"}]
> How can I parse it to name/value pairs in groovy script?
> Thanks,