JSONException if T cannot hold the contents of this JSONValue ConvException in case of integer overflow when converting to T
import std.exception; import std.conv; string s = `{ "a": 123, "b": 3.1415, "c": "text", "d": true, "e": [1, 2, 3], "f": { "a": 1 }, "g": -45, "h": ` ~ ulong.max.to!string ~ `, }`; struct a { } immutable json = parseJSON(s); assert(json["a"].get!double == 123.0); assert(json["a"].get!int == 123); assert(json["a"].get!uint == 123); assert(json["b"].get!double == 3.1415); assertThrown!JSONException(json["b"].get!int); assert(json["c"].get!string == "text"); assert(json["d"].get!bool == true); assertNotThrown(json["e"].get!(JSONValue[])); assertNotThrown(json["f"].get!(JSONValue[string])); static assert(!__traits(compiles, json["a"].get!a)); assertThrown!JSONException(json["e"].get!float); assertThrown!JSONException(json["d"].get!(JSONValue[string])); assertThrown!JSONException(json["f"].get!(JSONValue[])); assert(json["g"].get!int == -45); assertThrown!ConvException(json["g"].get!uint); assert(json["h"].get!ulong == ulong.max); assertThrown!ConvException(json["h"].get!uint); assertNotThrown(json["h"].get!float);
A convenience getter that returns this JSONValue as the specified D type. Note: Only numeric types, bool, string, JSONValue[string], and JSONValue[] types are accepted