Safely loading a hash in Ruby Safely loading a hash in Ruby json json

Safely loading a hash in Ruby


You should really be using YAML for this sort of stuff, your code is really risky.

YAML supports regexps and is fairly extensible.


Hashes and Arrays can be marshalled. This might be helpful if you want to store data from your program in a file. If you are interested in giving user a chance to provide data in external file you can take a look at YAML.