Another YAML bug?

V

Vladimir Marteev

Code:
#!/usr/bin/ruby1.8
require 'yaml'
a = { "b" => "c", "d" => nil, "e" => "f" }
puts a.to_yaml

result:

---
b: c
d:
e: f

but must be:
 
J

Jacob Fugal

Code:
#!/usr/bin/ruby1.8
require 'yaml'
a = { "b" => "c", "d" => nil, "e" => "f" }
puts a.to_yaml

result:

---
b: c
d:
e: f

but must be:

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] http://yaml.org/type/null.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,219
Messages
2,571,117
Members
47,730
Latest member
scavoli

Latest Threads

Top