digitalmars.D.learn - I can't believe this !!
- MesmerizedInTheMorning (9/9) Nov 13 2015 https://issues.dlang.org/show_bug.cgi?id=15331
- Rikki Cattermole (11/20) Nov 13 2015 in overload was introduced to JsonValue in 2.066.0 and it is still there...
- anonymous (17/26) Nov 13 2015 JSONValue supports `in`, though:
- MesmerizedInTheMorning (3/21) Nov 13 2015 What a relief...I should look at the source closer. I guess that
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 ?!
Nov 13 2015
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
Nov 13 2015
On 14.11.2015 07:30, 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 ?!JSONValue supports `in`, though: ---- import std.stdio; import std.json; void main() { foreach (jsonStr; ["{}", "{\"foo\": 42}"]) { JSONValue jsonObj = parseJSON(jsonStr); const JSONValue* p = "foo" in jsonObj; if (p is null) writeln("not found"); else writeln(*p); } } ---- Looks like documentation has been neglected.
Nov 13 2015
On Saturday, 14 November 2015 at 06:51:14 UTC, anonymous wrote:On 14.11.2015 07:30, MesmerizedInTheMorning wrote:What a relief...I should look at the source closer. I guess that the issue should be closed with RESOLVED INVALID.[...]JSONValue supports `in`, though: ---- import std.stdio; import std.json; void main() { foreach (jsonStr; ["{}", "{\"foo\": 42}"]) { JSONValue jsonObj = parseJSON(jsonStr); const JSONValue* p = "foo" in jsonObj; if (p is null) writeln("not found"); else writeln(*p); } } ---- Looks like documentation has been neglected.
Nov 13 2015