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?

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Olaf DoschkeSoftware 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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.