Groovy web console

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

test

Published 2 weeks ago by test with tags test
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def jsonString = '''{"message":"Correctly found locations.",    "success":true,    "users":{       "morpheus":[          {             "time":"2016-04-18 15:59:38.146929368 -0400 EDT",             "location":"office",             "bayes":{                "bed bath":-1.0796283868148098,                "bedroom":-0.3253323338565688,                "car":-0.11084494825121938,                "dining":-0.21592336935362944,                "kitchen":0.7779455402822841,                "living":-0.5328733505357962,                "office":1.486656848529739             }          }       ],       "zack":[          {             "time":"2016-04-20 07:27:47.960140659 -0400 EDT",             "location":"office",             "bayes":{                "bed bath":-1.028454724759723,                "bedroom":0.1239023145100694,                "car":-0.1493711750580678,                "dining":-0.4237049232002753,                "kitchen":0.6637176338607336,                "living":-0.701636080467658,                "office":1.515546955114921             }          }       ]    } }'''
def slurper = new groovy.json.JsonSlurper() 
def result = slurper.parseText(jsonString)

result.users.morpheus[0].location