Json.opIndex

Allows direct indexing of object typed JSON values using a string as the key.

Returns an object of Type.undefined if the key was not found.

  1. inout(Json) opIndex(size_t idx)
  2. const(Json) opIndex(string key)
  3. Json opIndex(string key)
    struct Json
    @safe ref @trusted
    opIndex
    (
    string key
    )

Examples

Json value = Json.emptyObject;
value["a"] = 1;
value["b"] = true;
value["c"] = "foo";
assert(value["a"] == 1);
assert(value["b"] == true);
assert(value["c"] == "foo");
assert(value["not-existing"].type() == Type.undefined);

Meta