Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't parse empty fields #4

Open
paleozogt opened this issue Jun 21, 2019 · 1 comment
Open

can't parse empty fields #4

paleozogt opened this issue Jun 21, 2019 · 1 comment
Labels
bug Something isn't working

Comments

@paleozogt
Copy link

Using empty fields in certain contexts won't roundrip.

Here we create a field called "a" with an empty value:

Yaml::Node root;
Yaml::Node &node = root["list"].PushBack();
node["a"] = "";

std::stringstream stream;
Yaml::Serialize(root, stream);
std::cout << stream.str() << std::endl;

Yaml::Node roundtrip;
stream.seekg(0, std::ios::beg);
Yaml::Parse(roundtrip, stream);

This outputs correct yaml, but it won't parse:

list: 
  - a: 

terminate called after throwing an instance of 'Yaml::ParsingException'
  what():  Incorrect offset. Line 2: 
@paleozogt
Copy link
Author

Oddly, increasing the size of the field name makes the problem go away.

Here we create a field called "abc" with an empty value:

Yaml::Node root;
Yaml::Node &node = root["list"].PushBack();
node["abc"] = "";

std::stringstream stream;
Yaml::Serialize(root, stream);
std::cout << stream.str() << std::endl;

Yaml::Node roundtrip;
stream.seekg(0, std::ios::beg);
Yaml::Parse(roundtrip, stream);

which outputs:

list: 
  - abc: 

@jimmiebergmann jimmiebergmann added the bug Something isn't working label Jul 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants