Empty field in yaml
PhpSymfonyYamlPhp Problem Overview
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:
Php Solutions
Solution 1 - Php
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: ~
Solution 2 - Php
If you want an empty string, rather than a null value, you can use two single quotes.
title:
1: String
2: String2
3: ''
Solution 3 - Php
According to YAML v1.2 spec:
> 10.3.2. Tag Resolution
> > Regular expression Resolved to tag > null | Null | NULL | ~ tag:yaml.org,2002:null > /* Empty */ tag:yaml.org,2002:null >
So putting null
or ~
or omitting value produces the same result: tag:yaml.org,2002:null
:
parent:
key1: # empty so "null", # is a comment!
key2: ~ # also "null"
key3: null # "null" explicitly ))
key4: !!null "null" # for the funs of "secondary tag handle: !!"
key5: "null" # sorry, it is a string or !!str if you like ((