What is and what is YAML for?

13
  • Briefly, what is YAML?

  • What are the advantages of using it?

asked by anonymous 14.08.2015 / 21:41

2 answers

13

Definition

YAML (a recursive acronym for YAML Is not Markup Language) is a human readable data encoding format.

Advantages

YAML was essentially done to save 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 looks like JSON can be partially interpreted by a parser of 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

  • YAML needs to be indented with spaces, if you use TAB an error will occur, this can be quite annoying at times.
  • Because of this need for spaces, YAML can quickly take up more space than JSON and XML.

    Although today's space is no longer a big problem, but if your project needs the data to be small, YAML might not be for you.

  • The performance of JSON is faster to interpret data. (Source: link )

  • Dependencies , many languages support XML and JSON by default, but not YAML.

My conclusion

If 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, and you'll probably need to use third-party libraries to make it work.

If I were to use YAML to save data I would soon like 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 because it takes up less space, and consequently, the user's internet data.

Sources and reference

15.08.2015 / 03:26
6

Yaml

Recursive acronym for YAML Ain’t Markup Language .

This is a human readable data serialization format, which is based on concepts such as XML , C , Python , Perl and also the e-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 not less generic than XML , YAML is much simpler to read, edit, modify, and produce than 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 has been de fi ned to only support characters in the UTF8 or UTF16 system, and parsers behavior is undefined when the YAML stream is in any other encoding.

Advantages

  • Readable by Humans.
  • Portable between programming languages.
  • Consistent model to support generic tools.
  • Expressive and extensible.
  • Easy to deploy and use.

What are the disadvantages of using XML and / or JSON

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

Reference:

YAML Documentation

    
15.08.2015 / 03:01