December 05, 2015 [Issue 15410] std.json documentation implies you *must* assign an AA literal to create an object | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=15410 bb.temp@gmx.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |bb.temp@gmx.com Resolution|--- |INVALID --- Comment #1 from bb.temp@gmx.com --- (In reply to Chris Wright from comment #0) > opIndex(string) says: > > "Throws JSONException if type is not JSON_TYPE.OBJECT." > > This implies the correct way to create a JSONValue of type OBJECT, assuming you don't want to use an AA literal, is: > > [...] > > However! The documentation is actually wrong! I can just write: > > --- > JSONValue j; > j["key"] = "value"; > --- > > That works! The documentation told me it would throw an exception, so there was no reason for me to try it. It was guaranteed to me that it would fail. But instead it succeeded. Your report is invalid. You say that 'opIndex(string)' ddoc specifies that it throws. But what you call is not opIndex(), it's opIndexAssign()!!! And 'opIndexAssign' ddoc says: /// Operator sets value for element of JSON object by key. /// If JSON value is null, then operator initializes it with object and then /// sets value for it. /// Throws JSONException if type is not JSON_TYPE.OBJECT or JSON_TYPE.NULL Your 'j' is initially null, then the call to opIndexASsign initializes j as a JSONObject. -- |
March 21, 2020 [Issue 15410] std.json documentation implies you *must* assign an AA literal to create an object | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=15410 Basile-z <b2.temp@gmx.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC|b2.temp@gmx.com | -- |
Copyright © 1999-2021 by the D Language Foundation