Ruby function similar to parse_str in php?
- by jolierouge
Hi,
I need to parse a string like this: a[metadata][][name]=dont|do|this&a[name]=Hello World&a[metadata][][value]=i|really|mean it
CGI::parse gives me this:
{"a[name]"=["Hello World"], "a[metadata][][name]"=["dont|do|this"], "a[metadata][][value]"=["i|really|mean it"]}
I would like something like what PHP does with parse_str, which when given the same string does this:
Array
(
[a] => Array
(
[metadata] => Array
(
[0] => Array
(
[name] => dont|do|this
)
[1] => Array
(
[value] => i|really|mean it
)
)
[name] => Hello World
))
Any help would be awesome.
Thanks!