jbeder / yaml-cpp

A YAML parser and emitter in C++
MIT License
5.09k stars 1.83k forks source link

String manipulators affect emitting numbers #1172

Closed NikOsint closed 1 year ago

NikOsint commented 1 year ago

For example, these lines make integers emit with double quotes too:

YAML::Emitter emitter;
emitter.SetStringFormat(YAML::EMITTER_MANIP::DoubleQuoted);

Is there a way to fix this so that only strings are emitted with quotes and integers without?

Other problem is that if I add quotes to a string by myself, it is then emitted with another pair of quotes, which looks like this:

"\"some string\""

My goal is to detect, whether a YAML entry is a string or not, by looking at presence of quotes around it (without tags).

jbeder commented 1 year ago

Unfortunately, yaml isn't the job for what you're trying to do. This is WAI for yaml-cpp. See the part of the YAML spec that talks about string types.