JsonTree getValue<string>() bug

Hi,

I think there is a bug in the templated getValue() function.
When the method is called with an std::string template and the string content includes blank spaces, the content is trimmed after the first blank space.

{
“foo” : “Lorem ipsum dolor”
}

this call returns "Lorem"
fooJson.getValue< string >();

this call works just fine and returns "Lorem ipsum dolor"
fooJson.getValue();

getValue<T> effectively a wrapper around boost::lexical_cast<T>. Should check the boost docs to see if casting from a string to a string is expected to behave the way you’re seeing. There should probably be a specialization for ci::fromString<T> for strings that just returns the original value though, i think.

Actually this recent PR removed the use of boost::lexical_cast. What version of cinder are you using (if master git branch, what commit)?

Not sure if / how it could be related, but JsonTree does some initial string parsing to support a syntax like data[foo.blah], maybe it is tripping up on the space in your value.

Probably also worth noting that we’re planning to deprecate ci::JsonTree in favor of just using jsoncpp directly. There’s little if any gain functionality wise in using cinder’s wrapper, it has some design issues, and requires boost containers, so we’d like to eventually remove it from the build.

master branch latest commit.

I see the same issue with XmlTree getting the value of a child.

getValue<std::string> and getValue returns the caracters before first blank.
Thais is with or without using the CDATA wrapper.

@xumo - apologies for the delay; I missed this message. I Believe a recent commit should fix this issue. Please let us know if you see otherwise.