majintao0131 / yaml-cpp

Automatically exported from code.google.com/p/yaml-cpp
MIT License
0 stars 0 forks source link

Nodes empty string as value test true with IsNull #124

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. create yaml doc with explicit empty strings.
2. Parse doc checking each node with IsNull(), before reading.

e.g.
Given a YAML doc like:

---
MyString: ""
...

and code like:

const YAML::Node *node = doc->FindValue("MyString");
if(node)
{
    if(!YAML::IsNull(*node))
    {
       std::string value;
       *node >> value;
       std::cout << "MyString has value [" << value << "]"
                 << std::endl;
    }
    else
    {
       std::cout << "MyString is null"
                 << std::endl;
    }
}

What is the expected output? What do you see instead?
Expected output is:
"MyString has value []"
Actual output is:
"MyString is null"

What version of the product are you using? On what operating system?
yamlcpp-0.2.5 on RHEL 5.7

Please provide any additional information below.

Original issue reported on code.google.com by benjamin...@gmail.com on 18 Oct 2011 at 9:38

GoogleCodeExporter commented 9 years ago
Thanks, definitely needs fixing.

Original comment by jbe...@gmail.com on 13 Jan 2012 at 6:01

GoogleCodeExporter commented 9 years ago
In the new API, this is fixed. It's not in the old API, but I don't think it's 
worth it.

Original comment by jbe...@gmail.com on 24 Jan 2015 at 11:35