On Thu, 24 Jul 2014 13:54:12 GMT, Etienne Cimon wrote:
It should be specified in the docs, but I always use
.to!
on theJson
object to verify its validity.
Be careful not to use .to!string
on a string though, because it will add quotes "
in that specific case. You must absolutely use .get!string on a string.
e.g.
auto j = Json.emptyObject;
if (someBool)
j["test"] = "hello";
string test;
if (j.test.to!bool == true){ // not undefined, length > 0
test = j.test.get!string;
assert(test == "hello");
test = j.test.to!string;
assert(test == "\"hello\"");
}
else
assert(test.to!string == "undefined");