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!
894359Asked:
Who is Participating?
 
Olaf DoschkeConnect With a Mentor Software DeveloperCommented:
Notice JSON is Javascript object notation. It's not a javascript object, it's a text notation of a javascript object, another terminus is it's a serialized object, where serialization means no more no less than to create a text representation of an object.

If JSON is returned from a web service that just means it returns a JSON string rather than XML or any other format.

The web application making requests to a web service returning JSON strings then can turn this into javascript objects.

The whole concept of web protocols doesn't allow transfer of anything "alive", like the instance of a class or an object, what's transferred always is text.

It's the same principle as the HTMl response of a webapplication to a request of a browser, it returns HTML, not the DOM, the document object model resulting from the HTML, the browser creates that DOM from the HTML just like the web application creates a javascript object from the JSON.

Bye, Olaf.
0
 
Julian HansenCommented:
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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.