我的休息 API 返回如下内容:
{"UserInfo":[{"userName":"zbradford","firstName":"Zoe","lastName":"Bradford","emailAddress":"ZBradford@ABC.COM"}]}
我想让它只返回电子邮件地址值:ZBradford@ABC.COM
这是我的代码:
import groovy.json.JsonSlurper;
def slurper = new JsonSlurper()
def jsonResponse = slurper.parseText(resp)
jsonResponse.UserInfo.emailAddress.join(',')
我收到一个 java null 错误,对我的代码有什么建议吗?谢谢