posting JSON vs traditional form encoding as the data format for submitting data to the server from a HTML form. The HTML form is dynamic as in, the user can add new rows (for example) and fill in data. There is an argument that using form fields with an MVC framework is easier in this case since the MVC framework like Spring MVC takes care of the bindings to the form (generating id's in the dynamically generated HTML etc) and we can have an object on the controller to collect these values when the form is posted using AJAX as a form encoded content type.
I was thinking of using JSON, what are your views?
Thanks for your time.
You can't compare this. What you can say is, either the traditional Submit is better or JSON way, but you need to take a choice. When submitting through JSON, you cannot send files, but it needs AJAX or similar technology to talk to the server. So browser compatibility to be checked.
The question itself is wrong. No is the answer, because most of the forms are submitted by POST
and the values are sent as serialized, which doesn't always mean JSON.
Again, the browser compatibility and users' bandwidth play a major role. If people have good browsers, go for it.
There are a set of rules and best practices available for designing web applications of all kinds. Kindly go through it and work on your project. :)
I would recommend that you stick with the standard format for the framework that you are using. In terms of performance, security and reliability the people developing your framework will generally do a much better job than you will at developing such infrastructure.
This article Normal form submission vs. JSON has a bit of a discussion on the topic of basic form submission vs JSON submission. One point which I agree with is that when you start getting into complex data structures, a structured format as opposed to a flat one can be quite advantageous. That said, as you said yourself, Spring MVC and other similar frameworks take care of the binding. For me, this is the one thing that JSON can do significantly better than standard form submission. If it is taken care of by default by the framework, stick with the default. Don't go adding complexity where it isn't necessary.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With