Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
82 lines (62 sloc) 2.36 KB


Bason is a Java toolkit to generate BSON serializer automatically. The mapper class configured in is generated at compile time which has no nagetive impact on performance (comparing with traditional reflection way).


Annotate your Java bean with @BsonDocument to declare that this bean can be serialized to or deserialized from bson.

public class Passenger {

	private double packageWeight;
	public double getPackageWeight() {
		return packageWeight;

	public void setPackageWeight(double packageWeight) {
		this.packageWeight = packageWeight;


For maven user, then add such segment on certain part of your pom.xml




if you are not maven user, add corresponding javac directive when compiling.

run maven compile to generate Bason manager class you defined in

See the example project for detail.

Bason snapshot builds are available at Sonatype OSS repository. Put this segment in you pom.xml:

		<id>sonatype oss snapshots</id>


Currently, you have to depend on whole mongo-java-driver which is considered to be verbose. I reported an issue to mongodb team. It is said that the bson packages will be distributed separately since the version of 2.2.