Groovy web console

subscribe to the feed Subscribe
to this
site

JsonSluper Example 2

Published 3 months ago by Amol Chavan
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
import groovy.json.JsonSlurper
JsonSlurper jsonSlurper = new JsonSlurper()

String txt = '{ "myList": [4, 8, 15, 16, 23, 42] }' 
Object result1 = jsonSlurper.parseText(txt) 
println result1.getClass() 
println (result1 instanceof List) 
println (result1 instanceof Map)