I have a bit of a problem with MongoDB in that it returns hashes with the keys in double quotes and integers as floats all the time, has this been a problem for anyone else?
for examples after a map reducing or grouping, say I have a bunch of hashes which look like this:
{"unknown"=>54.0, "pedestrians"=>572.0, "vehicles"=>1045.0}
But what I really want is:
{ unknown: 54, pedestrians: 572, vehicles: 1045 }
Any ideas on how I can easily convert it?
You could do:
Or if you’re using Rails, you could make it a
HashWithIndifferentAccessand just convert the values: