John Doe
John Doe

Reputation: 9764

GWT: working with JSON services

It's not a very concrete question. I created a simple project with a help of this tutorial, it's really fine. All the GWT code samples related to JSON I saw so far seem to work with a JSON (or immitate this work with some mock-up JSON), that is retrieved and processed in GWT. I'm a newbie in GWT, and I wonder, what are the cases of interacting with services that return JSON (services are mentioned in the same tutorial) and what are the pros and cons of such interaction.

I thought about two options (well, service is an overloaded term):

It's probably can't be fully explained in the answer, so a link (or a few) would be appreciated. Thanks in advance.

Upvotes: 1

Views: 409

Answers (1)

Ümit
Ümit

Reputation: 17499

Your question is really quite generic. But here are some pointers:

JSON is just a data interchange format similar to XML or Protocol Buffers or some other proprietary format.
They are necessary in modern web applications because the UI is entirely controlled by the javascript code running in the browser.
However the data that a web application presents to the user usually resides on the backend. In order to get the data from the backend to the frontend you have to use some data interchange format like JSON or XML.
The advantage of JSON is, that is fairly efficient compared to XML and well accepted.
As you mentioned there are third party services that rely on JSON. These are very useful when you want to include the services in your applications.
The biggest advantage of applying this service oriented approach to your own project is that you decouple your components (frontend and backend). By doing this you achieve following things:

  • Make your services available to other (web-)applications and users because your service exposes a specific API/data exchange format that they can use.
  • Easily replace or add another frontend (for example create a desktop application in addition to your GWT application) that can work with your data (display or modify).

Upvotes: 1

Related Questions