i have an object from a third party REST API. What I want to do is to iterate over each members of the object and get its key and value. The format of the object is like this :
{ 1st:"1", 2nd: "2", 3rd: "3rd" }
i have an object from a third party REST API. What I want to do is to iterate over each members of the object and get its key and value. The format of the object is like this :
{ 1st:"1", 2nd: "2", 3rd: "3rd" }
it's as simple as
hash = { ... } # result from api call
hash.each do |key, value|
# do your thing here
end
BTW, in ruby it's called "a hash", not "an object".