Groovy web console

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

assert json

Published 3 months ago by nmrao with tags json
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def response = """[   {
      "name": "John",
      "online_status": "online"
   },
   {
      "name": "Marry",
      "online_status": "online"
   }
]"""
def json = new groovy.json.JsonSlurper().parseText(response)
def result = json.collect{it.'online_status'} as Set
assert 1 == result.size()
assert result == ['online'] as Set