Hi all,

If we use the $.param(myobject) method to serialise an object, how can
we deserialise that string back to an object?

Maybe that function exists somewhere and I'm having a mental block.
Please help!

In the absence of such a method I would do something like this:

jQuery.extend({
        // The opposiite of jQuery's native $.param() method. Deserialises a
param string to an object:
        // Note: TODO: Allow for multiple params with same name (to become an
array attribute).
        unparam : function(params){
                var objResult = {};
                $.each(params.split("&"), function(){ var prm=this.split("=");
objResult[prm[0]] = prm[1]; });
                return objResult;
        }
});

Reply via email to