YAML and its Features
YAML Ain’t Markup Language was formerly called as Yet Another Markup Language. It is a human friendly data serialization language. It is basically used for configuration files. It can also be used for storing and exchanging data. It allows data to show itself in a natural and meaningful way.It is built upon structures and concepts described by python, XML, HTML, SOAP, Perl, C.
Why to use YAML?
- In YAML, data is portable between programming languages.
- It matches the native data structures of agile languages.
- It has a consistent model to support generic tools.
- Supports one-pass processing.
- Expressive and extensible.
- Easy to implement and use.
Basic rules and syntax :
- It is case sensitive
- It uses spaces, tabs are not allowed
- a line break is folded into a single space
- Yaml file starts with 3 hyphens(—) and ends with 3 dots(…)
- File extensions could be: .yaml or .yml
Primitive types in YAML :
- Basic type : Stores numeric, string and boolean values
- Mapping : A form of associative arrays or hash or dictionary
- Sequences : Includes list or array
Use cases of YAML:
- Configuration files
- Cross language data sharing
- Inter process messaging
- Importing and exporting data to and from server
- Intermediate data storing
Comparison of YAML with
- YAML is a superset of JSON, hence JSON data will be parsed by the YAML compiler.
- JSON doesn’t allow commenting while YAML does.
- Yaml is more robust than jSON.
- Unlike YAML in JSON, values need to be quoted.
- XML is a markup language while YAML is more of a data format.
- YAML provides more readable and editable format.
- XML has a more mature ecosystem.