Tuesday, April 24, 2012

How to change array index to start from 1?

How can I change my array's indices to start from 1 instead of 0. I am trying to fetch news from a site (JSON) and after parsing it:



@news = JSON.parse(Net::HTTP.get(URI.parse('http://api.site.com/news?format=json')))


But to see the individual news title, I have to do @news["items"][0] for the first link's title. Is it possible to change that behavior so when I do @news["items"][1] it shows me the first link's title?





No comments:

Post a Comment