Reputation: 4286
I'm learning about API's, I came across the fact that web services always return either XML or JSON data.
Why those specific languages?
Upvotes: 1
Views: 64
Reputation: 169
Simplest and structured way to define data over the XML and Json. And Mostly all the programming language can support parsing both XML and Json. The way both XML and Json reading,writing also faster compare to other file structure.
Upvotes: 0
Reputation: 12413
Although the most common, web services can return anything over a HTTP stream binary data, string data, video streams etc. XML and JSON are just very popular for returning data.
XML and JSON are not languages. They are structures in which data can be returned. Both have the advantage of being (just about) human readable, and of containing enough meta information to make sense of the returned data, and are flexible enough to store a complex object. The key is often "serialization" - a programming language builds an object, the object is serialized as XML or JSON, and the serialzied representation returned.
Upvotes: 3
Reputation: 2349
XML and JSON aren't languages, rather they are different approaches to sending structured data.
Languages, such as Javascript, C#, and Python (and hundreds more) can read data when it is structured in either JSON or XML.
XML was invented first and quickly lost popularity when JSON came onto the scene as it's easier to use. But XML still has some good features that some people can't live without, and XML is used by older systems so still supported for legacy's sake.
Use google and do searches around JSON v XML to understand more, but don't get dragged into the argument.
Both represent data, JSON is more popular and easier to understand.
Upvotes: 2