David Rodenas PhD
1 min readAug 6, 2024

--

Well, JSON and XML are different and store information in a different manner.

For example, JSON is to store data structures. It resembles 1 to 1 with almost any language internal data structures and it creates a really structured language. So... structure XD

Meanwhile, XML is to store documents. I know, there are a lot of people that uses it to store data... but it has lot of flaws and lot of probably -does not have to- additional irrelevant information.

For example, in XML if you do <A><B /> <B/><A> it is relevant for the format that, given that it is a document. That information is that all of those are on the same line, so there are no line breaks, that the element A contains several Bs, but Bs are separated by one space. Yet, if you do in JSON { type: 'A', children: [ { type: 'B' }, { type: 'B' }] }, it is clear what is going on and what are you representing.

And although JSON seems more verbose, it is very clear about its semantics. Yes, XML is also very clear, but often part of its actual semantics are ignored.

So, that's why XML didn't make the cut to represent date, but it is great for things like documents or representing UI (like JSX). In those, being concise is great and new lines and spaces can be a great deal.

--

--

David Rodenas PhD
David Rodenas PhD

Written by David Rodenas PhD

Passionate software engineer & storyteller. Sharing knowledge to advance our skills. Join me on a journey of discovery in the world of software engineering.

Responses (1)