Dynamically create Javascript Object
It seems odd to special-case the string "object" when preparing an object for serialization, so I came up with the following code:

var createObjectFromParam = function (o, prop, val) {
    var parts = prop.split('.');
    var last = o;
    while (parts.length) {
        var part = parts.shift();
        if (parts.length &gt; 0) {
            last[part] = last[part] || {};
            last = last[part];
        } else {
            last[part] = val; // Add conditional expressions here
        }
    }
    return last;
}


The code does the following:


Creates a temporary variable (last) to contain the current "level" of the object hierarchy.
Loops through the array. Note that while (parts.length) will stop the loop when there are no longer parts in the array.
Take the next part of the prop. shift pulls the first element of the array out.
If we're not at the last element


If the element with the specified name exists at the level, use that
If not, create an object at that level

Otherwise, add a property with the specified value to the object.
Finally, return the created object.


Given the example in the jsFiddle (updated here), this would produce the following structure:

{
    "ready": {
        "set": "go"
    },
    "another": "object",
    "happy": {
        "happy": {
            "joy": "joy",
            "foo": "bar",
            "happy": "happy"
        }
    }
}


To keep that original special-casing, just replace the commented line with something like:

last[part] = val === 'object' ? {} : val === 'undefined' ? : undefined : val;