Skip to content

Commit

Permalink
Add introduction to YAML features
Browse files Browse the repository at this point in the history
  • Loading branch information
Integralist committed Sep 9, 2014
1 parent d4be341 commit 34bb8a8
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,21 @@ ruby \
ruby -rjson -ryaml -e "puts JSON.generate(YAML.load_file('EC2.yml'))" | json_pp
```

## Yaml Features
## YAML Features

YAML provides a couple of features to help reduce complexity and duplication.

To reduce complexity, YAML will allow values to not be quoted. What this means
is that YAML will intelligently recognise the data type of your content. So if
you write `123` then it'll interpret this as an integer, but if you write `abc`
then it'll interpret that as a String. But there is one item worth noting: if
you write `Yes` then YAML will interpret that as `true`. If you really mean `Yes`
to be a String then either write it as `"Yes"` (i.e. quoted) or use YAML's
explicit data typing feature: `!!str Yes` (which is ugly, so best use quotes).

To reduce duplication, YAML provides an "anchor" (`&`) which let's us tag a key
and to then "reference" (`*`) that tag later on in our document. We demonstrate
this in the below YAML example file (and in the JSON conversion after it).

```yaml
my_json:
Expand Down

0 comments on commit 34bb8a8

Please sign in to comment.