I have a form with the following format (only parts of the form)
<input type="text" name="Journal[data][serviceaddress][company]" value="{{company}}"/>
<input type="text" name="Journal[data][serviceaddress][address]" value="{{address}}"/>
<input type="text" name="Journal[data][serviceaddress][zip]" value="{{zip}}"/>
<textarea name="Journal[data][serviceaddress][notes]">{{notes}}</textarea>
<input type="text" name="Journal[rows][1][title]"/>
<input type="text" name="Journal[rows][1][body]"/>
<input type="text" name="Journal[rows][2][title]"/>
<input type="text" name="Journal[rows][2][body]"/>
I'd like to convert this to the following JSON-object
{
data:{
serviceaddress:{
company: "companyvalue",
address: "addressvalue",
zip: "zipvalue",
notes: "notesvalue"
}
},
rows:{
1:{
title: "row1title",
body: "row1body"
},
2:{
title: "row2title",
body: "row2body"
}
}
}
Which would be the best way to do this? I thought that i must be someone who did this already, but all i found when searching was people wanting the input name as the key and not nested JSON-data...