I create a hash in ruby with integer keys and send it as a JSON response. This JSON is then parsed and the hash is converted back to ruby. The keys are now string literals.
I get it that JSON doesnt support integer keys but I came upon this method which basically parses the hash so that it has symbol keys.
JSON.parse(hash, {:symbolize_names => true})
Is there a similar function for obtaining back the original integer keys
a = {1 => 2}
a.keys
=> [1]
b = JSON.parse(JSON.generate(a))
b.keys
=> ["1"]
My hash is very complicated. The value itself is a hash which is supposed to have integer keys. There are multiple such levels of nesting