What is it and what is YAML for?

Asked

Viewed 8,142 times

16

  • Briefly, what is YAML?

  • What are the advantages of using it?

  • What are the disadvantages in its use compared to XML and/or JSON?

2 answers

16


Definition

YAML (recursive acronym for YAML Ain’t Markup Language) is a human-readable data encoding format.

Perks

The YAML was done essentially to store data (as well as databases).

Regarding XML and JSON readability is much easier and you write more easily. In addition, it is very well documented and has several libraries.

I did not confirm, but it seems that JSON can be partially interpreted by a parser yaml.


YAML

blog:
       nome: Café = linhas
       url: http://exemplo.com

       post:
              titulo: hello world
              data: 12/04/2011


JSON

{
  "blog": {
    "nome": "Café = linhas",
    "url": "http://exemplo.com",
    "post": {
      "titulo": "hello world",
      "data": "12/04/2011"
    }
  }
}


XML

<?xml version="1.0" encoding="UTF-8" ?>
<blog>
    <nome>Café = linhas</nome>
    <url>http://exemplo.com</url>
    <post>
        <titulo>hello world</titulo>
        <data>12/04/2011</data>
    </post>
</blog>

Disadvantages

My conclusion

Whether your file can be edited manually by a user (as was the case with the Bukkit project). YAML may be a good choice, but I see no advantage to any other cases.

It can take up more space and is less performative, plus you probably need to use third-party libraries to make it work.

If I were to use YAML to store data I would prefer to use a database as Mysql or Sqlite. If I were to send data to an API I would choose JSON or XML, preferably JSON for taking up less space, and consequently, user internet data.

Sources and reference

    1. O YAML precisa ser identado com espaços, se você usar TAB um erro ocorrerá, isso pode ser bem irritante as vezes. - That’s no disadvantage, it’s an advantage for consistency.
    1. Devido a essa necessidade de espaços o YAML pode rapidamente ocupar mais espaço que o JSON e o XML. - this statement is not completely wrong because you used "can"! JSON has quotes for key/value, brackets, keys. I’m not even going to talk about XML because it’s extremely verbose: YAML is just to be a dry XML for data. Even in machine code, remember that YAML can also be minified, taking advantage of the fact that it contains JSON as a partial subset.

7

Yaml

Recursive acronym for YAML Ain’t Markup Language.

It is a human-readable data serialization format, which was inspired by concepts of languages such as XML, C, Python, Perl and also the electronic mail format specified in RFC 2822. It was proposed by Clark Evans in 2001 and designed in conjunction with Ingy döt Net and Oren Benkiki.

Although it is no less generic than the XML, the YAML is largely simpler to read, edit, modificar and produce than the XML. That is, almost everything that is possible to represent in XML can be represented in YAML, and at the same time, in a more compact way. The YAML was definido to support only characters in UTF8 or UTF16 system, parsers' behavior being undefined when stream YAML is in any other encoding.

Perks

  • Human-readable.
  • Portable between programming languages.
  • Consistent model to support generic tools.
  • Expressive and extensible.
  • Easy to implement and use.

What are the disadvantages in its use compared to XML and/or JSON?

Advantage is that it is easier to read, disadvantage that is more complex to generate and analyze.

Reference:

YAML documentation

Browser other questions tagged

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