vibe.d beta banner
get vibe.d
0.8.1

Asynchronous I/O that doesn’t get in your way, written in D

Module vibe.data.bson

BSON serialization and value handling.

Example

import vibe.core.log : logInfo;

void manipulateBson(Bson b)
{
	// retrieving the values is done using get()
	assert(b["name"].get!string == "Example");
	assert(b["id"].get!int == 1);

	// semantic conversions can be done using to()
	assert(b["id"].to!string == "1");

	// prints:
	// name: "Example"
	// id: 1
	foreach (string key, value; b) {
		logInfo("%s: %s", key, value);
	}

	// print out with JSON syntax: {"name": "Example", "id": 1}
	logInfo("BSON: %s", b.toString());

	// DEPRECATED: object members can be accessed using member syntax, just like in JavaScript
	//j = Bson.emptyObject;
	//j.name = "Example";
	//j.id = 1;
}

Functions

NameDescription
deserializeBson(dst, src)Deserializes a BSON value into the destination variable.
fromBsonData(v)
serializeToBson(value, buffer)Serializes the given value to BSON.
toBigEndianData(v)
toBsonData(v)

Structs

NameDescription
BsonRepresents a BSON value.
BsonBinDataRepresents a BSON binary data value (Bson.Type.binData).
BsonDateRepresents a BSON date value (Bson.Type.date).
BsonObjectIDRepresents a BSON object id (Bson.Type.binData).
BsonRegexRepresents a BSON regular expression value (Bson.Type.regex).
BsonSerializerSerializes to an in-memory BSON representation.
BsonTimestampRepresents a BSON timestamp value (Bson.Type.timestamp).

Aliases

NameTypeDescription
bdata_timmutable(ubyte)[]
Authors

Sönke Ludwig

Copyright

© 2012-2015 RejectedSoftware e.K.

License

Subject to the terms of the MIT license, as written in the included LICENSE.txt file.