Hassan Schroeder wrote in post #1119612:
> On Mon, Aug 26, 2013 at 12:42 PM, Love U Ruby <lists@ruby-forum.com>
> wrote:
>>
>> My question is how should I get the hash {1=>2,3=>{4=>5,6=>7}} from that
>> string?
>
> Why don't you generate valid JSON in the first place?
>
> `{1=>2,3=>{4=>5,6=>7}}.to_json` would show you what the string
> should look like (and why your example is so broken).
Humm.. its working now..
require 'json'
JSON.parse({1=>2,3=>{4=>5,6=>7}}.to_json)
# => {"1"=>2, "3"=>{"4"=>5, "6"=>7}}
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/e69b59d116935cd2bdbc7e966225009a%40ruby-forum.com.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment