Differences between using XML or JSON

Asked

Viewed 681 times

2

I want to understand why use XML or JSON, and why have little XML content on the internet? XML is already "dead"?

  • The question is totally valid. Perhaps only sources of the statements made in the question were missing.

1 answer

4


XML is far from having died, still has an absurdity of things in XML, including there its variations as XAML just to cite one example (there are several others with similar purpose), many configuration files use. XML was created to be extensible and not to be used purely because it is too simple. XML has a number of features that JSON does not have, for example you type the data with schema and use of namespace, and make it canonical.

JSON is much simpler and was created precisely for this, when you don’t need everything XML needs. JSON is used by most Apis because it is lighter than XML to carry and even to build and decode, the gain can impact in large volumes.

In general if it’s to use something simple then one could use something different like YAML And something like that, but JSON took it and people don’t often wonder why they’re using it, almost everyone thinks if they’re using it, they should use it, too. Of course, if you are going to exchange data with third parties then adopting the standard is important. YAML has its disadvantages there, so another format, perhaps proprietary, is more interesting for your case.

XML is used for things that need more reliability, security and stability, one of the examples we use the most is in tax matters in Brazil (Nfe and company) and in many platforms EDI traditional.

The fact that you see little content is just a bias of your own, that’s how the fake news, the person considers that his perception is more important than the fact.

You can see more in Why and when to use XML instead of JSON?.

JSON XML
Simple Complex and powerful
Easy to parse Difficult
Quick to parse Slow
Map Tree
Data without semantics Semantic information
Unceremonious Greater control
Schemaless (implicitude) Schema (explicitude)
Data-only Metadata
Free raw use Sophisticated mechanism
Nameless Namespace
Data transfer format Markup language
Born from use with Javascript Derivative of SGML
Easy to learn Difficult
Free data Document
"Unreliable" "Reliable"
Readable "Illegible"
Basic data Rich data
Allows array Simulate array
No Comments Commentary
UTF-8 standard Configurable
Little space Wastage
Serialization Configuration/Validation

Of course some of these things are optional or can be solved with some addendum that the technology allows and that someone did, for example have a schema in JSON. Not everything that seems is necessarily bad. For example, if you compress the data the XML is the same size as the compressed JSON, but of course JSON takes less time to compress.

XML has lost market, but that’s dying?

Google trends de XML X JSON

  • I’m sorry I didn’t ask a trick question. rs But I’m waiting for the rest of the content, I’m starting to understand better. Thank you very much friend.

Browser other questions tagged

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