# IT:AD:JQuery:Libs:SerializeForm #
* [[../|(UP)]]
{{indexmenu>.#2|nsort tsort}}
* [http://zensoftware.org/archives/445](http://zensoftware.org/archives/445)
* ***Note:*** that it has to be used on containing div, not the form itself...
## Notes ##
* Pros:
* unlike JQuery's Serialize (which produces a string output), serializes things as a Map.
* ie: This is beneficial for JSON requests.
* Cons:
* The fact that it can work from Id's if there is no Name, is not really a plus...
* Serializes Names with "_" instead of "." (as keys can't contain ".") which will cause problems with deserializing nested objects.
* As it is a key, and not a string, it doesn't serialize Checkboxes as two entries (which is what the MVC framework was expecting), but as a single key with two values separated by comma.
ie, instead of serializing the checkbox and the hidden field that MVC puts in there (with the same name) as:
MyCheckBox=true&MyChecBox=false
it comes out as:
[MyCheckBox:true,false]
This in turn gets serializes as a form post:
MyCheckBox:true,false
which causes MVC to fail deserialzing it back to the original Model bool property, and so all checkboxes remain false... Not good.
## For JSON ##
Note that
$('#formid').serializeArray();
returns a Map. Move towards `JSON.stringify`
## Future ##
* [http://stackoverflow.com/questions/3515523/javascript-how-to-generate-formatted-easy-to-read-json-straight-from-an-object](http://stackoverflow.com/questions/3515523/javascript-how-to-generate-formatted-easy-to-read-json-straight-from-an-object)
* Consider: [http://stackoverflow.com/questions/2552836/convert-an-html-form-field-to-a-json-object-with-inner-objects](http://stackoverflow.com/questions/2552836/convert-an-html-form-field-to-a-json-object-with-inner-objects)