Read more

YAML: Keys like "yes" or "no" evaluate to true and false

Henning Koch
May 14, 2014Software engineer at makandra GmbH

If you parse this Yaml ...

yes: 'Totally'
no: 'Nope'
Illustration web development

Do you need DevOps-experts?

Your development team has a full backlog? No time for infrastructure architecture? Our DevOps team is ready to support you!

  • We build reliable cloud solutions with Infrastructure as code
  • We are experts in security, Linux and databases
  • We support your dev team to perform
Read more Show archive.org snapshot

... you get this Ruby hash:

{ true: 'Totally',
  false: 'Nope' }

In order to use the strings 'yes' and 'no' as keys, you need to wrap them with quotes:

'yes': 'Totally'
'no': 'Nope'

There's actually a long list of reserved words Show archive.org snapshot with this behavior:

y|Y|yes|Yes|YES|n|N|no|No|NO
|true|True|TRUE|false|False|FALSE
|on|On|ON|off|Off|OFF

I'm sorry.

Posted by Henning Koch to makandra dev (2014-05-14 15:16)