Link to home
Start Free TrialLog in
Avatar of MJ
MJFlag for United States of America

asked on

How/What Do Web Services Return when Creating a JSON Data Layer?

Excuse my ignorance on this subject but is there a standard used when creating a JSON object as a data-layer for a web application from a web service?  The part I don't understand is if I have a web service that returns data and the end result is to create a JSON object used as a  data-layer, Is it usually the Web application takes the data from the web service and creates the data-layer or is it the web service returns the JSON object complete? Or could it be either way?

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of Olaf Doschke
Olaf Doschke
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Is it usually the Web application takes the data from the web service and creates the data-layer or is it the web service returns the JSON object complete? Or could it be either way?

Typically you have the following
A model (database)
a web service
a web service consumer (client app)

When you query a web service, it builds a data model to return and then converts that into a representation that can be sent to a remote client.

Your data model could be anything from a string to a complex C structure. The web service will convert this into
JSON
XML
HTML
CSV
or a Custom format

And return the data as text.

The client will receive the response from the service and will then convert it into a local representation of the model in whatever environment that may be.

So to answer your question, the web service will convert the response into JSON (where a JSON service is implemented) and return the JSON string. The consumer (client) will convert the string into whatever format it needs to work with it - in JavaScript that would be a JavaScript object.

JSON and XML (SOAP) are common formats but the service can return anything provided that the return format is constant and documented.