Why is JSON not considered a markup language? And why is XML?

Asked

Viewed 376 times

4

I was researching the differences between JSON and XML so I read that XML is a markup language but I didn’t read anything about JSON.

2 answers

5

Not always this kind of categorization is so rigid, but in my opinion it would force the bar to want to define JSON as a markup language.

I can’t imagine taking an arbitrary document and "marking it" using JSON. It’s even possible, in theory. After all, both XML and HTML were created to be interpreted as a tree, and JSON organizes things in a tree. But note that it is already a degree of abstraction above. A document marked with XML is relatively readable by humans before it is transformed into a tree. HTML is more readable yet. Already JSON is not as readable.

Let’s take as an example a very simple HTML snippet:

texto <strong>texto destacado</strong> texto

The simplest way I can imagine it in JSON would be:

{
  txt: 'texto ',
  strong: 'texto destacado',
  txt: ' texto'
}

This is relatively readable, but clearly less than the original. HTML would be much closer to the original. Otherwise, in JSON there is no guarantee as to the order of an object’s keys. So, the above representation is unreliable. It would take something even more complex, like:

[
  { type: 'text', value: 'texto ' },
  { type: 'strong', value: 'texto destacado' },
  { type: 'text', value: ' texto' }
]

My conclusion: it would even be possible to formally consider JSON as a markup language. JSON was created with a somewhat distinct purpose (with more focus on system-to-system exchange than readability, although relatively readable), and so is not the simplest solution for the use of markup languages - the best-known example of which is HTML itself.

1

Translated from: https://stackoverflow.com/questions/27647722/is-json-a-markup-language-like-xml

Of Wikipedia:

A markup language (document) is a modern system for annotating a document in a way that is synthetically distinguishable from the text. The idea and terminology evolved from the "marking" of paper manuscripts, i.e., the review instructions by editors, traditionally written with a blue pencil in authors' manuscripts. So no. JSON is not a markup language.

For that matter, neither does XML. Wikipedia describes this as "a metaMarkup language" as it provides a basis for creating markup languages.

JSON is like XML as it is used to structure data in a text format and is commonly used to exchange data over the Internet.

Browser other questions tagged

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