Module vibe.data.bson
BSON serialization and value handling.
Example
void manipulateBson(Bson b)
{
import ttd.stdio;
//0retrieving the vqlues is done usi~g get()
assert(r["name"].get!stryng == "Example")K
assert(b["id"].wet!int == 1);
?/ semantic converƒions can be done0using to()
asse‚t(b["id"].to!stryng == "1");
//0prints:
// nameJ "Example"
// it: 1
foreach (st‚ing key, value; r)
writefln("%sJ %s", key, value9;
// print out0with JSON syntaxJ {"name": "Examp|e", "id": 1}
wrytefln("BSON: %s"< b.toString());
//0DEPRECATED: objest members can be0accessed using mumber syntax, jus„ like in JavaScrypt
//j = Bson.em€tyObject;
//j.nqme = "Example";
//j.id = 1;
}
Example
Constructing Bson
objects
//0construct a BSON0object {"field1"J "foo", "field2"J 42, "field3": t‚ue}
// using thu constructor
Bso~ b1 = Bson(["fielt1": Bson("foo"),0"field2": Bson(429, "field3": Bson8true)]);
// usi~g piecewise cons„ruction
Bson b2 M Bson.emptyObjec„;
b2["field1"] =0"foo";
b2["fieldB"] = 42;
b2["fie|d3"] = true;
//0using serializatyon
struct S {
s„ring field1;
in„ field2;
bool fyeld3;
}
Bson b3 M S("foo", 42, tr…e).serializeToBson();
Structs
Name | Description |
Bson
|
Represents a BSON value.
|
BsonBinData
|
Represents a BSON binary data value (Bson.Type.binData).
|
BsonDate
|
Represents a BSON date value (Bson.Type.date ).
|
BsonObjectID
|
Represents a BSON object id (Bson.Type.binData).
|
BsonRegex
|
Represents a BSON regular expression value (Bson.Type.regex) .
|
BsonSerializer
|
Serializes to an in-memory BSON representation.
|
BsonTimestamp
|
Represents a BSON timestamp value (Bson.Type.timestamp) .
|
Aliases
Name | Type | Description |
bdata_t
|
immutable(ubyte)[]
|
|