std.json API improvement - Request for code review

Brian Schott brian-schott at cox.net
Sun Sep 12 02:05:09 PDT 2010


Now that a few bugs are fixed in DMD (notably 4826), my improvements to
std.json compile. My primary purpose in this code change is streamlining
the process of creating JSON documents. You can now do stuff like this:

auto json = JSONValue();
json["numbers"] = [1, 3, 5, 7];
json["nullValue"] = null;
json["something"] = false;
json["vector"] = ["x": 234.231, "y" : 12.8, "z" : 35.0];
assert("vector" in json);
json["vector"]["x"] = 42.8;

More example usage:
http://www.hackerpilot.org/src/phobos/jsontest.d

The implementation of the actual JSON data structure and parsing /
writing is unchanged. Ddoc comments were added so that the documentation
page for the module won't be quite so empty.

Implementation:
http://www.hackerpilot.org/src/phobos/json.d

I'd like to get this committed back to Phobos if there's a consensus
that these changes make sense. Comments welcome. (Note: You'll need a
DMD version built from SVN to use this)

- Brian


More information about the Digitalmars-d mailing list