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. Keys are now string literals.
I get that JSON does not support whole keys, but I came across this method, which basically parses the hash so that it has character keys.
JSON.parse(hash, {:symbolize_names => true})
Is there a similar function to return 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 that must have integer keys. There are several levels of nesting.
source share