This repository has been archived by the owner on Mar 25, 2024. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #319
This PR handles pre-YAML 1.2 bool keywords (
on
,off
,yes
,no
, etc.) during serialization to add single quotes which adds backwards compatibility when the serialized YAML is later loaded by a YAML parser for an older spec.1.1 Reference: https://yaml.org/type/bool.html
Notable changes
y
which is now serialized with quotes as well (e.g.'y': 0
). I think this is desirable because some YAML implementations can interpret the field as a regular YAML value (and you end up with a boolean key), however I have yet to find that in the YAML spec.Previous content
This PR modifies
crate::de::parse_bool()
to treaton/ON/yes/YES/off/OFF/no/NO
as bool as per the YAML 1.1 spec. The same change also causes string values with these values to be quoted, which fixes #319.I couldn't find whether
serde-yaml
aims to be compatible with a particular YAML spec version; the fact that it did not support on/off/etc. before suggest that it may be targeting YAML 1.2(.2?).Serializing these words with quotes is backwards compatible, however if we start to deserialize them as bool this may be breaking to consumers of
serde-yaml
. I would suggest to consider eitherYamlVersion
enum and default toYamlVersion::V1_2
, which foregoes matching the on/off/etc. wordsparse_bool()
during serialization so that we serialize treating these words as bool but don't during deserialization