Reputation: 91
I know that by default yamp-cpp emits strings without quotes but, if there are brackets in the string it always emit it with double quotes.
YAML::Emitter out;
// ...
const std::string myStr = "[0, 0, 1]"
out << myStr;
In the above example I get in the file: "[0, 0, 1]" when I want [0, 0, 1]
Do you know how to solve that?
Thanks!
Upvotes: 1
Views: 939
Reputation: 425
You could try this:
YAML::Emitter out;
// ...
const std::string myStr = "[0, 0, 1]"
out << YAML::Load(myStr);
or this:
out.WriteStreamable(myStr);
Upvotes: 0
Reputation: 34054
The reason yaml-cpp is quoting your string is that if it didn't, you'd be emitting a sequence, not a scalar. If you want to emit the sequence [0, 0, 1]
, then you can do so:
out << YAML::BeginSeq << 0 << 0 << 1 << YAML::EndSeq;
But you simply can't emit the text [0, 0, 1]
as a plain scalar, since it's not!
Upvotes: 2