// parse a simple number JSONValue a = toJSONValue(`1.0`); assert(a == 1.0); // parse an object JSONValue b = toJSONValue(`{"a": true, "b": "test"}`); auto bdoc = b.get!(JSONValue[string]); assert(bdoc.length == 2); assert(bdoc["a"] == true); assert(bdoc["b"] == "test"); // parse an array JSONValue c = toJSONValue(`[1, 2, null]`); auto cdoc = c.get!(JSONValue[]); assert(cdoc.length == 3); assert(cdoc[0] == 1.0); assert(cdoc[1] == 2.0); assert(cdoc[2] == null); import std.conv; JSONValue jv = toJSONValue(`{ "a": 1234 }`); assert(jv["a"].to!int == 1234);
parseJSONValue
Parses a JSON string or token range and returns the result as a JSONValue.
The input string must be a valid JSON document. In particular, it must not contain any additional text other than whitespace after the end of the JSON document.