Incorrect handling of special keys when writing YAML files
Closed this issue · 0 comments
dalum commented
I've run into some issues where the writer produces files that cannot be parsed again, when string keys are present, which start with special characters. A few examples are:
for char in [
"{", "}", "[", "]", "&", "*", "#", "?", "|", "-", "<", ">",
"=", "!", "%", "@", ":", "`", ",", "'", "\"",
]
d = Dict(char => 0.0)
@test YAML.load(YAML.yaml(d)) == d
end
As an example, YAML.yaml(Dict(">" => 0.0))
produces:
>: 0.0
which does not parse.
By comparison, Python's YAML writer successfully handles these by quoting the key:
In : yaml.dump({">": 0.0})
Out: "'>': 0.0\n"