0

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" }

1 Answers1

0

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".

Sergio Tulentsev
  • 219,187
  • 42
  • 361
  • 354