Converting to hash

I have hash of common_id as follows:

{ “signin” =>

     "element1" =>

                  { "ios_id => "i1", "android_id" => "a1" }

     "element2" =>

                { "ios_id => "i2", "android_id" => "a2" }

}

trying to convert it so that I can fetch the value as:

ids[“signin”][“elment1”] => “i1”

How can I convert the ids hash to get above result.

“i1” in your code is a value not a hash key.

You seem to be attempting to use “=>” to access a value for a key. If
so, that is not the correct syntax.

What does your test code look like?

Scott S. wrote in post #1169176:

“i1” in your code is a value not a hash key.

You seem to be attempting to use “=>” to access a value for a key. If
so, that is not the correct syntax.

What does your test code look like?

currently to access “i1” value I have to write:
ids[“signin”][“element1”][“ios_id”] = “i1”

so now, what I am trying to achieve is,
I have 2 values for ids, ios_id and android_id. I have to iterate over
the ids and build new hash which would be like:

ids[“sign”][“element1”] having value “i1”.
means new hash will be having all ios_id value for all element.

ids[“signin”][“element1”] = “i1”
ids[“signin”][“element2”] = “i2”
ids[“signin”][“element3”] = “i3”
ids[“signin”][“element4”] = “i4”

I am trying:

ids.each do |key, value|
value.each do |k, v|
new_id_hash[“signin”] = Hash.new
if v.has_key?(“ios_id”) then
[ Insert the value of ios_id key to new_id_hash ]
[ new_id_hash[“signin”][“element1”] = “i1”]
end
end
end