On Thursday, 24 July 2014 at 15:59:52 UTC, Daniel Gibson wrote:
Am 24.07.2014 17:54, schrieb Pavel:
Guess what, here's a new snippet:
import std.stdio;
import std.json;
void main() {
scope(failure) writeln("FaILED!!");
string jsonStr = `{ "name": "1", "type": "r" }`;
auto parsed = parseJSON(jsonStr).object;
writeln("fail" in parsed);
}
Output is:
null
WAT?!
Ofcourse, writing like:
writeln(cast(bool)("fail" in parsed));
Produces "false"... but why on earth boolean expression would
output null?
PS: Sorry, for such an emotional boom, I'm so frustrated right
now.
Relax :-)
And see http://dlang.org/hash-map.html
"in" doesn't just return if something is in a map.
If it is, it returns a pointer to the value, otherwise null.
Thus null.
Cheers,
Daniel
Thanks to all you folks who explained "in" operator for me. My
bad.
Let's focus on the real problem, which is JSON wrapper class.
Is it needed? Wouldn't it be better to get AA from parseJSON?