0

So I'm trying to do some work with JIRA's REST API to get our upcoming releases schedule. From their API I can get returned JSON as seen below:

[{
"self": "https://jira.company.com/rest/api/2/version/15701",
"id": "15701",
"description": "First release",
"name": "1.4.3",
"archived": false,
"released": true,
"releaseDate": "2013-02-28",
"userReleaseDate": "28/Feb/13",
"projectId": 10005
},
{
"self": "https://jira.company.com/rest/api/2/version/15685",
"id": "15685",
"description": "Second release",
"name": "1.4.5",
"archived": false,
"released": true,
"releaseDate": "2013-03-11",
"userReleaseDate": "11/Mar/13",
"projectId": 10005
}
]

So I've looked over other answers on the site and I can't quite figure out when I have a block that doesn't have an identifier. For example this question, reddit's api names each json object while JIRA does not. Ruby - iterate over parsed JSON

I've tried something along the lines of

json[''].each do |release|
    puts release['description']
end

But that's where I'm a bit lost. I put [''] because there is no key to go off there. I'm quite new to JSON so my terminology might be way off here too...

Community
  • 1
  • 1
Danny
  • 5,180
  • 6
  • 26
  • 29

1 Answers1

2

You will be given an Array object when you parse that JSON string.

If you write the following code:

json.each do |release|
  puts release['self']
end

You should see this output:

https://jira.company.com/rest/api/2/version/15685
https://jira.company.com/rest/api/2/version/15701
Chris Ledet
  • 11,458
  • 7
  • 39
  • 47