Reputation: 2787
I have this HTML code :
<input type="checkbox" name="search-form[filters][category][12]" value="cat-12" autocomplete="off" checked="checked" />
<input type="checkbox" name="search-form[filters][category][14]" value="cat-14" autocomplete="off" checked="checked" />
When I´m using the jQuery function serializeArray()
like this :
var $postForm = $("#myForm");
console.dir( $postForm.serializeArray() );
I got this :
[
{
"name": "search-form[filters][category][12]",
"value": "cat-12"
},
{
"name": "search-form[filters][category][14]",
"value": "cat-14"
}
]
How can I get this :
[
{
"search-form"{
"filters" : {
"category" : {
"12" : { "value" : "cat-12" },
"14" : { "value" : "cat-14" }
}
}
}
}
]
Upvotes: 0
Views: 64
Reputation: 189
Following git repository may solve your problem.
https://github.com/marioizquierdo/jquery.serializeJSON
Form input, textarea and select tags are supported. Nested attributes and arrays can be specified by using the attr[nested][nested] syntax.
Upvotes: 1