Home > Net >  What is a markup language? (XML vs YAML vs JSON)
What is a markup language? (XML vs YAML vs JSON)

Time:09-22

Can someone explain to me what a markup language is? Why XML is a markup language and why YAML and JSON are not?

I've read many articles but none of those are giving any kind of examples. If someone can help me to understand this with some examples, that'd be great!

CodePudding user response:

The purpose of markup languages such as XML is to represent documents, whereas the purpose of data serialization languages such as YAML or JSON is to represent data. Examples follow:

XML

<document>
  <paragraph>This is a <i>small</i> document</paragraph>
<document>

YAML

customer:
    first_name: John
    last_name:  Smith
    dob:        2000-01-01

JSON

{
  "customer":
    {
      "first_name": "John"
      "last_name": "Smith"
      "dob": "2000-01-01"
    }
}

Historically, there has been plenty of cross-over use, but originally as well as currently, the document vs data distinction best characterizes the difference.

See also

CodePudding user response:

The term "markup" originates with the hand-written marks used by copy editors (human beings) to indicate changes that need to be made to a text, or styling to be applied to the text (such as italics, justification, or paragraph breaks). See for example https://www.pinterest.co.uk/pin/407927678731145164/ Typically these are instructions to the type-setter (also a human being!) who would be responsible for creating first galley proofs and then final paginated copy.

The essence of markup is therefore annotating a text to supply editorial meta-information for use in preparing final copy. SGML, XML, and HTML are firmly in that tradition.

Use of XML as a data transfer syntax was another way of applying the same technology, but it's not what markup was designed for. JSON and YAML work well as a data transfer syntax, but they don't work well for annotating texts.

  • Related