> How can I parse it to name/value pairs in groovy script?

I would recommend getting the Groovy binary distribution (we use 2.4.X) and
experimenting with that. Aside from us throwing in a few of the NiFi APIs,
it's a standard Groovy environment. You'll flatten the learning curve on
writing these scripts if you approach it that way.

Thanks,

Mike

On Wed, Sep 5, 2018 at 9:34 AM Matt Burgess <mattyb...@apache.org> wrote:

> 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 <lvic4...@gmail.com> 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,
>

Reply via email to