Search code examples
rubyregexstringparsingrhomobile

Ruby/Rhomobile: parse directory string representation



I have a string that looks like this: {"whatever-field"=>"gghyduudud"}
I'd like to parse it so that it becomes a hash.

Please help.

Thanks!


Solution

  • You can use eval, but only if the data source is absolutely reliable:

    >> eval('{"whatever-field"=>"gghyduudud"}')
    => {"whatever-field"=>"gghyduudud"}