Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

YAML: dictionary with empty value

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

like image 813
flybywire Avatar asked May 07 '09 10:05

flybywire


People also ask

Can YAML have empty values?

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.

How do you give an empty value in YAML?

You can use ~ or null .

Is an empty string valid YAML?

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.


1 Answers

key: 

is parsed as null -

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

The correct answer is:

key: "" 
like image 143
Andrey Avatar answered Sep 26 '22 11:09

Andrey