Groovy web console

subscribe to the feed Subscribe
to this
site
test parsed array (via #groovywebconsole)
tweet this snippet Tweet
this
script

test parsed array

Published 2 months ago by rh
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
import groovy.json.JsonSlurper

def data  = '''{"root": {"second": [{"array":"titi"}, {"array":"toto"}]}}'''
def slurper = new JsonSlurper()

def parsed = slurper.parseText(data)

parsed?.root?.second?.each { arg ->
    println arg.array
}

return null