Reputation: 87
I have a hash that I want to extract the values from, but when I try its empty.
When I display the variable with the hash this is what shows.
{"raspado"=>{"id"=>28520497, "name"=>"Raspado", "profileIconId"=>508, "summonerLevel"=>30, "revisionDate"=>1394570420000}}
When I debug the variable with the hash this is what I get.
---
raspado:
id: 28520497
name: Raspado
profileIconId: 508
summonerLevel: 30
revisionDate: 1394570420000
When I try to access a key via
debug @data[:id]
I get
---
...
what I'm I doing wrong?
Upvotes: 0
Views: 153
Reputation: 6928
If you have multiple keys like 'raspado
in the hash', then you could get the values with the code below:
@data.each do |index, values|
debug (values['x'])
end
ref: How do I get data from a hash?
Upvotes: 1
Reputation: 160953
id
is the key in the hash which is the value of key raspado
of @data
.
You should do:
debug @data['raspado']['id']
Upvotes: 1