dtolnay / serde-yaml

Strongly typed YAML library for Rust
Apache License 2.0
960 stars 157 forks source link

Recognizing more boolean representations #379

Closed jonathan-s closed 1 year ago

jonathan-s commented 1 year ago

I'm looking at this PR https://github.com/dtolnay/serde-yaml/pull/330/files and see that you've explicitly chosen to represent some values such as Y etc as strings rather than booleans.

According to the yaml spec https://yaml.org/type/bool.html these should be considered booleans. Would you be amenable to accept a change in this behaviour? Most other (all that I know, except this one) yaml parsers do in fact convert these values to boolean values.

dtolnay commented 1 year ago

The page you linked is not part of the YAML spec.

jonathan-s commented 1 year ago

This link here > https://yaml.org/spec/1.1/#id864510 should be part of the spec as far as I understand.

In that paragraph it's written

YAML allows scalar content to be presented in several formats. For example, the boolean “true” might also be written as “yes”. Tags must specify a mechanism for converting any formatted scalar content to a canonical form for use in equality testing. Like node style, the format is a presentation detail and is not reflected in the serialization tree and representation graph.

Reflecting that yes is part of what should be represented as a boolean.

The section on tags. Also links to the link I mentioned first. It's the link for "bool"

The repository includes additional types such as “null”, “bool”, “set” and others.

dtolnay commented 1 year ago

That new link is at least 14 years out of date.

As far as I am able to discern, here is the spec that defines what values to interpret implicitly as bool: https://yaml.org/spec/1.2.2/#1032-tag-resolution. This was linked in the summary of my PR that you linked to at the top.

jonathan-s commented 1 year ago

I stand corrected. Thank you for taking the time to reply.