以下是GitHub从REST GET方法返回的内容。如何使用JSON解析它?
response.success = { resp, reader ->
result = reader.text
}
[{"login":"ghost","id":1,"avatar_url": ....},{"login":"github-enterprise","id":2,"avatar_url": ....}]
答案 0 :(得分:1)
你可以使用很棒的工具来处理json - json slurper
:
def slurper = new JsonSlurper()
def result = slurper.parseText(result)
def firstLogin = result[0].login
def secondId = result[1].id