For example the form contains fields with the following names txt01, txt02, txt03[], txt03[], txt04[name][], txt04[name][], txt04[phone][], txt04[phone][], txt05[][name], txt05[][phone], txt05[][name], txt05[][phone]. When I input values to those fields and click the submit button it should generate the below Json Object:
Object {
txt01: "Text 01",
txt02: "Text 02",
txt03: Array(2) {
0: "Text 01",
1: "Text 02"
},
txt04: Object
{
name: Array()
{
0: Text 01
1: Text 02
},
phone: Array()
{
0: 000001
1: 000002
}
},
txt05: Array(2)
{
0: Object
{
name: Text 01
phone: 000001
},
1: Object
{
name: Text 02
phone: 000002
}
}
}
Below is the form that is to be serialize to Json Object. The script that will perform the serialization should generate the above Json Object.
<form>
<input type="text" name="txt01" value="Text 01" />
<input type="text" name="txt02" value="Text 02" />
<input type="text" name="txt03[]" value="Text 01" />
<input type="text" name="txt03[]" value="Text 02" />
<input type="text" name="txt04[name][]" value="Text 01" />
<input type="text" name="txt04[name][]" value="Text 02" />
<input type="text" name="txt04[phone][]" value="000001" />
<input type="text" name="txt04[phone][]" value="000002" />
<input type="text" name="txt05[][name]" value="Text 01" />
<input type="text" name="txt05[][phone]" value="000001" />
<input type="text" name="txt05[][name]" value="Text 02" />
<input type="text" name="txt05[][phone]" value="000002" />
<input type="submit" value="Submit" />
</form>