I am trying to access Jira Rest API using Groovy. (And this question is not Jira-specific.)
There is no problem on connection; I can get the JSON data that I want.
When I tried to iterate over a JSON array in the data; I failed. However, if I tried to access the JSON array's value at specified index; I can get the data.
String out_json = get("https://jiraserver.intra/rest/api/2/search/?jql=project%20%3D%20TEST%20ORDER%20BY%20key%20ASC&startAt=0&maxResults=1", authString); // It returns the json data
def out = new JsonSlurper().parseText(out_json)
def key = out.issues[0].key // I can access the key this way
for(int i = 0; i < size; i++){
out.issues[i].key // And it returns null
break;
}
For the one who doesn't know the JSON, it is something like:
{
"total": 2,
"issues": [
{
"key": "TEST-1"
-- some other key-values --
},
{
"key": "TEST-2"
-- some other key-values --
}
]
}
What am I missing?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…