Have you tried to put all fields in arrays?
<fieldset name="address"> <input name="address[streetAddress]" type="text" placeholder="Street Address"><br> <input name="address[city]" type="text" placeholder="City"><p>,</p> <input name="address[state]" type="text" placeholder="State"> <input name="address[zipCode]" type="text" placeholder="Zip Code"> </fieldset>
Here is an example using the serializeObject plugin
Just include the script and you can convert any form into a layered JSON object.
DEMO HERE
Using this plugin ... more details here Converting form data into JavaScript object using jQuery
(function($){ $.fn.serializeObject = function(){ var self = this, json = {}, push_counters = {}, patterns = { "validate": /^[a-zA-Z][a-zA-Z0-9_]*(?:\[(?:\d*|[a-zA-Z0-9_]+)\])*$/, "key": /[a-zA-Z0-9_]+|(?=\[\])/g, "push": /^$/, "fixed": /^\d+$/, "named": /^[a-zA-Z0-9_]+$/ }; this.build = function(base, key, value){ base[key] = value; return base; }; this.push_counter = function(key){ if(push_counters[key] === undefined){ push_counters[key] = 0; } return push_counters[key]++; }; $.each($(this).serializeArray(), function(){
Kylek source share