jQuery.serializeObject 0.1

I found myself in a situation recently where I wanted to have access to variables that would have been posted, in a the same structure as if the form had been posted and returned the JSON, using this jQuery plugin and Douglas Crockford's JSON library, I think I've done it!

The form below has elements in CakePHP FormHelper style names (data[User][name], data[User][email], etc) so when they're posted to PHP you get deep arrays ($_POST['data']['User']['name'], $_POST['data']['User']['email'], etc), which you can then turn into JSON ({data:{User:{name:'blah',email:'blah'}}}).

You can download the script here.

You can test out the script using the form below: