1

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

1

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
  • 226,338
  • 43
  • 373
  • 367