BSON.opIndexAssign

Allows accessing fields of a BSON object using [].

Returns a null value if the specified field does not exist.

  1. inout(BSON) opIndex(string idx)
  2. void opIndexAssign(T value, string idx)
    struct BSON
    @safe
    void
    opIndexAssign
    (
    T
    )
    (
    in T value
    ,
    string idx
    )

Examples

BSON value = BSON.emptyObject;
value["a"] = 1;
value["b"] = true;
value["c"] = "foo";
assert(value["a"] == BSON(1));
assert(value["b"] == BSON(true));
assert(value["c"] == BSON("foo"));
auto srcUuid = UUID("00010203-0405-0607-0809-0a0b0c0d0e0f");

BSON b = srcUuid;
auto u = b.get!UUID();

assert(b.type == BSON.Type.binData);
assert(b.get!BSONBinData().type == BSONBinData.Type.uuid);
assert(u == srcUuid);

Meta