I'm working on an app that stores the application state to the
navigation bar. I use Hash.toQueryString() and it beautifully converts
multidimensional arrays to subscript values. For example:
a => 1
b => 2
c => [3, 4, 5]

gets converted to a=1&b=2&c[0]=3&c[1]=4&c[2]=5

Now, how do I get that string back into a Hash? I've implemented a
String.toHash() method:

String.implement({
                                 toHash: function() {
                                         var hash = new Hash();
                                         this.split("&").each(function(item) {
                                              hash.include(item.split("=")[0],
item.split("=")[1]);
                                          });
                                         return hash;
                                 }

                                 });

But, of course, it's not multidimensional array-aware.

I started writing up some code to parse it, but it got really gross
really quickly. Any ideas of an elegant solution?

Thanks for the tips!

Reply via email to