Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Empty field in yaml

Tags:

php

yaml

symfony

I want to leave a value in my .yaml field empty, because in another translation there has to be something but not in this one. Just leaving it empty prints out the path of the value (...title.3).

title:     1: String     2: String2     3: 
like image 657
maidi Avatar asked Dec 04 '15 13:12

maidi


People also ask

Can YAML have empty value?

Representing null values in YAML There are several ways to represent null values in YAML. Empty values are also considered to be null values.

How specify empty value in YAML?

You can use ~ or null . Show activity on this post. If you want an empty string, rather than a null value, you can use two single quotes.

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.

What are the nulls expressed with in YAML?

Nulls. Nulls in YAML can be expressed with null or ~ .

What is empty array in YAML with example?

Following is an example for dictionary types of data. [] denotes an empty array in yaml. the empty array defined using a key is a variable of type string, value is an empty array like below

What does[] mean in YAML?

[] denotes an empty array in yaml. the empty array defined using a key is a variable of type string, value is an empty array like below

How do I convert null YAML values to empty strings?

An example of converting null YAML values to empty strings when using ytt for Kubernetes config templating. This approach uses Python's boolean short-circuiting behavior to concisely substitute empty strings for None values. It was inspired by this Stack Overflow post.

Are keys in the string array optional in YAML?

Keys in the string array are optional in YAML. Here is an example of an array of strings with keys. Numbers are predefined scalar types in yaml.


2 Answers

You can use ~ or null.

You should read documentation of YAML and you can read Symfony Yaml Format as well

title:     1: String     2: String2     3: ~ 
like image 89
Robert Avatar answered Sep 21 '22 14:09

Robert


If you want an empty string, rather than a null value, you can use two single quotes.

title:     1: String     2: String2     3: '' 
like image 41
Alex von Brandenfels Avatar answered Sep 21 '22 14:09

Alex von Brandenfels