On 14/11/15 7:30 PM, MesmerizedInTheMorning wrote:
https://issues.dlang.org/show_bug.cgi?id=15331

but it's true !

There's **nothing** to check the availability of a Key. At least I would
expect opIndex[string key] to return a JSONValue with .type ==
JSON_TYPE.NULL, but no...

Also If it was returning a JSONValue* it would be easyer to check if a
key is present.

God damn it, how could you miss this design flaw when std.json was
reviewed ?!

in overload was introduced to JsonValue in 2.066.0 and it is still there.

https://github.com/D-Programming-Language/dlang.org/blob/cbb94142ac52e9c57648b10708aedfa55711fe47/changelog/2.066.0.dd#L1042

As per the unittest:

    ///
    unittest
    {
        JSONValue j = [ "language": "D", "author": "walter" ];
        string a = ("author" in j).str;
    }

https://github.com/D-Programming-Language/phobos/blob/master/std/json.d#L538

Reply via email to