Groovy web console

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

compare json with map

Published 6 months ago by nmrao with tags compare map
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def expectedMap = ['data' :'test', 'success' :'true', 'statuscode' :'200']

def response = """{
      "data": "test",
      "success": "true",
      "statuscode": "500"
}"""

def json = new groovy.json.JsonSlurper().parseText(response)
assert json == expectedMap