Skip to content
This repository was archived by the owner on Mar 25, 2024. It is now read-only.
This repository was archived by the owner on Mar 25, 2024. It is now read-only.

Preserve double quotes around "yes" and "no" strings #319

@RandomGHUser

Description

@RandomGHUser

I am having an issue with preserving string values of "yes" and "no" after converting from str -> yaml value -> (string/str). "yes" is not the same as yes (YAML version 1.1 interprets the latter as bool). Is there a setting or flag I can set to preserve the double quotes around strings yes and no, so they do not get interpreted as bools?

let _str = r#"
QuoteYes: "yes"
QuoteNo: "no"
RegYes: yes
RegNo: no
"#;
let to_yaml = serde_yaml::from_str::<serde_yaml::Value>(_str).unwrap();
let to_str = serde_yaml::to_string(&to_yaml).unwrap();
std::fs::write("./test.yaml", &to_str);

expected output file:

QuoteYes: "yes"
QuoteNo: "no"
RegYes: yes
RegNo: no

actual output file:

QuoteYes: yes
QuoteNo: no
RegYes: yes
RegNo: no

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions