Reinventing the wheel is a pet hate of mine; I could list quite a few actually, but that's not the point of this post. Sometimes it takes me so long to look for a wheel that I think has or should have already been invented that it would have been easier just to invent the wheel myself.
Recently I was playing around with jquery, pulling fields from a form and posting them as a JSON object to a set of services. Nothing fancy, nothing difficult there. However, when the data model started to mature beyond the most basic structure I soon realised I need an easy, repeatable way to pull structured/nested data from a a form and convert it into a JSON object prior to posting.
To create the following structure:
You will need to create the following references:
This is a complete working example that will parse the form, create the JSON obbject, POST it to a service and display the returned object in a table.
The form above will produce the following JSON.