2

I'm designing the architecture for a new web application. I think that communications between the backend (server) and the frontend should be JSON only. Here are my arguments:

  • Its the client responsibility to manipulate and present data in its own way. The server should just send to the client the raw information needed.
  • JSON is lightweight and my application might be used by remote clients over poor mobile connections
  • It allows multiple front-end developments (Desktop devices, mobile devices) and has the potential to create an API for other developers

I can't see any counter-argument to this approach, considering that we have internally the frontend skills to do almost everything we need from raw JSON information.

Could you provide counter-arguments to this JSON-only choice so that I can make a more informed choice? There must be some as a lot of backend frameworks (think about the php ones) still advertise HTML templating to send HTML formatted responses to the clients. Thanks

UPDATE: Even though I researched the topic before, I found a similar and very interesting post: Separate REST JSON API server and client?

Community
  • 1
  • 1
user3213968
  • 31
  • 1
  • 4

2 Answers2

1

There are many front end based framework already in market which support a Json very efficiently,some of them are backbone,underscore,angular etc.Now if we talk about backend,we generally use REST based communication for such type of application.So i think this type of architecture already exits in market and working very well,specially if i talked about mobile based application.

Innovation
  • 1,514
  • 17
  • 32
  • Even when we use python based Django framework or flask framework we generally send data in the form of raw json and at client side JSON is parsed and appropriate values are displayed in UI. – Innovation Jan 20 '14 at 06:33
  • Thanks for your answer. Indeed this approach is already used. I'm still wondering why other approaches are still used. For example, PHP frameworks generating HTML. Is it because of a lack of front-end skills (I mean the ability to write good Javascript code) ? – user3213968 Jan 20 '14 at 23:02
  • Ya it can be one of the reason.As developers usually want to work more on backend and don’t want to work on frontend.Also peoples don’t want to learn latest technologies.Also in previous systems if already some technology is using ,so it is assumed that let it be work like this only and they not want to try new/different things. – Innovation Jan 21 '14 at 04:48
1

Although this question is dead, I think I should try to weigh in.
For all the reasons you stated and more, communication between the back-end and front-end via only JSON files is maybe the best way available, as it provides a more compartmentalized structure for your web application, and at the same time drastically reduces the data sent over your users' connection.
However, some drawbacks that are a direct consequence of this are:

  • Need for a lot more JavaScript front-end development (as the HTML structure is not being sent by the server and needs to be created in the client)
  • It shifts the pressure from the server to the client, thus there is more JavaScript for the client to run (this can sometimes be a problem especially for mobile users)
liakoyras
  • 1,101
  • 12
  • 27
  • I could be wrong, but I think you can address those issues by using server-side rendering. – Max Aug 02 '23 at 19:19
  • If you render on the server side, then you will have to send the rendered page (html) to the client, thus defeating the purpose of the question which was to use json only (data only) communication. Unless I misunderstood you. – liakoyras Aug 03 '23 at 14:53