Groovy web console

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

assert json

Published 1 year 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