JSON x Web Services

Asked

Viewed 600 times

1

1 - What is the difference between JSON and Web Services? (Only the format type in return)?

2 - In terms of performance, which would be better?

3 - In practice I should use JSON (with a php or java file for example) to integrate my applications directly with AJAX or Mobile (Ios and Android) and Web Services when I want other people to have access to it?

Thank you

2 answers

2

It’s not a matter of "difference".

Web services are "API’s" to access data through HTTP protocol. Any form of HTTP communication to transfer data between applications can be called a web service.

There are several ways to structure your "API" using HTTP as a means of transport. The industry has developed and adopted the SOAP, using a huge set of protocols to exchange XML information over HTTP. SOAP gained a very corporate bias and became complex, so some developers adopt XML-RPC, which is more informal.

Initially, XML was used even when the API client was a web application in a browser, but eventually dropped the plug that decoding XML in the browser was too heavy and that it would be simpler to deliver content in JSON, which is nothing more than Javascript’s native data structure.

So JSON is just the data transfer format used by web services. If your web services are consumed by browser applications, it is only natural that you opt for JSON. If they are consumed by other applications, maybe XML makes more sense. Since both are only formats for the same information, development frameworks (Rails, for example) often allow the same web service to return JSON or XML according to the client’s request.

0

You are confusing things. Web service is an access point from one device (a server for example) to other devices (browsers or other servers) in the WWW, whereas JSON is a format for data representation. Webservices may use JSON or some other format for (XML, YAML, HTML, plain text, etc.) to transmit data, or may accept input data in some (or several) of these formats.

The question you want to ask is probably "what communication protocol should I use for my webservice, REST, SOAP or other?" and "which data transfer format would be the most advised?" in which case my advice is to use it to REST as communication protocol (which is basically HTTP only) and JSON as data format.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.