chyh1990 / yaml-rust

A pure rust YAML implementation.
Apache License 2.0
601 stars 138 forks source link

`True` and `False` boolean literals seem to be parsed as strings #196

Open reivilibre opened 6 months ago

reivilibre commented 6 months ago

https://github.com/chyh1990/yaml-rust/blob/da52a68615f2ecdd6b7e4567019f280c433c1521/src/yaml.rs#L307-L308

I am actually really struggling to understand the YAML 1.2 spec here, but I think it's saying that a parser can be in one of two modes: JSON schema tag resolution, or core schema tag resolution (with core seemingly being recommended as a default). https://yaml.org/spec/1.2.2/#1022-tag-resolution

From my reading:

In any case, my colleagues used to YAML 1.1 were taken by surprise when True wasn't working for them. I am not sure what the right answer is here, but I suspect these boolean literals should still be treated as valid booleans.

hoodie commented 5 months ago

AFAIK the yaml 1.2 spec is smaller and more strict than 1.1. That's why a number of different representations for true and false are now treated as strings (including yes and no). The reference you provide is really curious, I haven't found any reference about how to communicate to the parser which schema to follow. How would I mark a document/value to be understood as JSON schema tag resolution or core schema tag resolution?

davvid commented 5 months ago

This repo is basically unmaintained. I would recommend moving this discussion to a new issue in https://github.com/Ethiraric/yaml-rust2 where it'll have a better chance of resulting in improvements.