[code]
#!/usr/bin/ruby1.8
require 'yaml'
a = { "b" => "c", "d" => nil, "e" => "f" }
puts a.to_yaml
[/code]
result:
[code]
#!/usr/bin/ruby1.8
require 'yaml'
a = { "b" => "c", "d" => nil, "e" => "f" }
puts a.to_yaml
[/code]
result:
Not a bug.
According to [1] the canonical representation for !!null is indeed
'~', but the empty string (as well as the tokens 'null', 'Null' and
'NULL') are also acceptable representations. And we needn't worry
about confusion with the empty string since the empty string must be
represented with quotation marks, e.g.:
d: ""
There may be an argument that the YAML serialization of Ruby's nil
*should* be '~' instead of an empty string, but it is not the case
that it *must* be so.
Jacob Fugal
[1] Null Language-Independent Type for YAML™ Version 1.1
On 11/22/06, Vladimir Marteev <xor104@gmail.com> wrote:
[code]
#!/usr/bin/ruby1.8
require 'yaml'
a = { "b" => "c", "d" => nil, "e" => "f" }
puts a.to_yaml
[/code]result:
---
b: c
d:
e: fbut must be:
---
b: c
d: ~
e: f