<p>I've been developing a "Form Builder" in Javascript, and coming up to the part where I'll be sending the spec for the form back to the server to be stored. The builder maintains an internal data structure that represents the fields, label, options (for select/checkbox/radio), mandatory status, and the general sorting order of the fields.</p>

<p>When I want to send this structure back to the server, which format should I communicate it with?</p>

<p>Also, when restoring a server-saved form back into my Javascript builder, should I load in the data in the same format it sent it with, or should I rebuild the fields using the builder's <code>createField()</code> functions?</p>

[{'answer_id': 16535, 'author': 'juan', 'author_id': 1782, 'author_profile': 'https://Stackoverflow.com/users/1782', 'pm_score': 0, 'selected': False, 'text': "<p>I'd implement some sort of custom <code>text serialization</code> and transmit plain text. As you say, you can rebuild the information doing the reversed process.</p>\n"}, {'answer_id': 16538, 'author': 'Barrett Conrad', 'author_id': 1227, 'author_profile': 'https://Stackoverflow.com/users/1227', 'pm_score': 3, 'selected': False, 'text': '<p>When making and processing requests with JavaScript, I live and breath <a href="http://json.org/" rel="noreferrer">JSON</a>.  It\'s easy to build on the client side and there are tons of parsers for the server side, so both ends get to use their native tongue as much as possible. </p>\n'}, {'answer_id': 16547, 'author': 't3rse', 'author_id': 64, 'author_profile': 'https://Stackoverflow.com/users/64', 'pm_score': 2, 'selected': False, 'text': '<p>This seems like a perfect scenario for using <code>JSON</code> as a serialization format for the server. If you study a few <a href="http://www.json.org/example.html" rel="nofollow noreferrer">examples</a> it is not too difficult to understand.</p>\n'}, {'answer_id': 16549, 'author': 'AAA', 'author_id': 1977, 'author_profile': 'https://Stackoverflow.com/users/1977', 'pm_score': 2, 'selected': True, 'text': '<p>Best practice on this dictates that if you are not planning to use the stored data for anything other than recreating the form then the best method is to send it back in some sort of native format (As mentioned above) With this then you can just load the data back in and requires the least processing of any method.</p>\n'}, {'answer_id': 16551, 'author': 'Kibbee', 'author_id': 1862, 'author_profile': 'https://Stackoverflow.com/users/1862', 'pm_score': 0, 'selected': False, 'text': "<p>There's a lot of people who will push <code>JSON</code>. It's a lot lighter weight than <code>XML</code>.  Personally, I find <code>XML</code> to be a little more standard though.  You'll have trouble finding a server side technology that doesn't support <code>XML</code>. And <code>JavaScript</code> supports it just fine also.<br>\nYou could also go a completely different route. Since you'll only be sending information back when the form design is complete, you could do it with a <code>form submit</code>, for a bunch of hidden fields. Create your hidden fields using <code>JavaScript</code> and set the values as needed.<br>\nThis would probably be the best solution if didn't want to deal with <code>JSON/XML</code> at all.</p>\n"}]
['https://Stackoverflow.com/questions/16529', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1951/']