YAML: dictionary with empty value

flybywire picture flybywire · May 7, 2009 · Viewed 28k times · Source

How do I write in YAML a dictionary (map) where one key has the empty string as its value?

Answer

Andrey picture Andrey · May 7, 2009
key:

is parsed as null -

%YAML 1.1
---
!!map {
    ? !!str "key"
    : !!null "null",
}

The correct answer is:

key: ""