Reputation: 2375
The following is what GitHub returns from a REST GET method. How to parse it using JSON?
response.success = { resp, reader ->
result = reader.text
}
[{"login":"ghost","id":1,"avatar_url": ....},{"login":"github-enterprise","id":2,"avatar_url": ....}]
Upvotes: 0
Views: 1897
Reputation: 4907
You can use awesome tool for working with json - json slurper
:
def slurper = new JsonSlurper()
def result = slurper.parseText(result)
def firstLogin = result[0].login
def secondId = result[1].id
Upvotes: 1