You can map JSON to specific class in Groovy using as
operator:
import groovy.json.JsonSlurper
String json = '''
{
"name": "John",
"age": 20
}
'''
def person = new JsonSlurper().parseText(json) as Person
with(person) {
assert name == 'John'
assert age == 20
}