Searched for tag YAML and found 1 results in 0.5 ms

YAML is growing on me

The more I learn about YAML, the more I like it. JSON is great as a machine readable format, but it sucks at being human readable. Want to add an element, better make sure you have all the commas and curly braces in the exact right place or the whole thing will be unusable. YAML on the other hand is designed to be human readable and modifiable. It's a very simple key/value system using indentation to represent layers.

PHP has a PECL module with good YAML support. There are also pure PHP versions if you're unable to install PECL modules. Symfony provides one, and so does Spyc. I prefer the latter because it's a single file and very easy to install.

On the Perl side there is YAML::XS, YAML::PP, and many others.

Parsing YAML is very easy in just about every language I can find. If you have a complex data structure that you need humans to interact with use YAML please.

Here is a great breakdown of when to use YAML vs JSON:

Use Case Recommended Why
API request/response JSON Universal support, strict parsing
Configuration files YAML Comments, readability
Browser/JavaScript JSON Native parsing
Kubernetes/Docker YAML Industry standard
Data interchange JSON Unambiguous, fast
Human-edited files YAML Less punctuation
Tags:
Leave A Reply