How do I write in YAML a dictionary (map) where one key has the empty string as its value?
Empty values: null can be used to represent an empty value, such as an empty list or an empty string. Placeholder values: null can be used as a placeholder value when the actual value is not yet known. Missing or incomplete data: null values can be used to represent data that is missing or incomplete.
You can use ~ or null .
As you can see, since both l-document-prefix and l-any-document are optional, an empty YAML stream is valid – but contains no document. If you're asking whether l-any-document can produce the empty string, the answer is no. Without a starting --- , you have an l-bare-document which must contain at least one node.
key:
is parsed as null -
%YAML 1.1 --- !!map { ? !!str "key" : !!null "null", }
The correct answer is:
key: ""
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With