8
down vote
If you are on Groovy 1.8 or later, there is a build in JsonSlurper you can use this way:
import groovy.json.JsonSlurper//Attention: you have to use double quotes inside the json stringdef jsonObj =newJsonSlurper().parseText('{ "name":"Peter", "age": 23}')assert jsonObj.name =="Peter"assert jsonObj.age ==23//this won't work, because it's not definedassert jsonObj.gender ==null