6

Improved MongoDB compatibility for bson4jackson

 2 years ago
source link: https://michelkraemer.com/improved-mongodb-compatibility-for-bson4jackson/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Improved MongoDB compatibility for bson4jackson

Ver­sion 1.2.0 of bson4­jack­son has just been re­leased. bson4­jack­son adds sup­port for BSON, a bin­ary rep­res­ent­a­tion of JSON, to the Jack­son JSON pro­cessor. Thanks to con­tri­bu­tions from the com­munity, the latest re­lease of bson4­jack­son now in­cludes bet­ter sup­port for Mon­goDB.

Gergő Ertli has fixed the sup­port for the ObjectId type. Ob­ject IDs are used as the primary key for Mon­goDB doc­u­ments.

Sup­port for the UUID type has been ad­ded by Ed Anuff. He ad­ded a new mod­ule which can be re­gistered to Jack­son’s ObjectMapper:

ObjectMapper om = new ObjectMapper(new BsonFactory());
om.registerModule(new BsonUuidModule());

Thanks to the con­tri­bu­tion by James Roper the BsonParser class now sup­ports the new HONOR_DOCUMENT_LENGTH fea­ture which makes the parser honor the first 4 bytes of a doc­u­ment which usu­ally con­tain the doc­u­ment’s size. Of course, this only works if Bson­Gen­er­ator.­Fea­ture.­EN­ABLE_STREAM­ING has not been en­abled dur­ing doc­u­ment gen­er­a­tion.

This fea­ture can be use­ful for read­ing con­sec­ut­ive doc­u­ments from an in­put stream pro­duced by Mon­goDB. You can en­able it as fol­lows:

BsonFactory fac = new BsonFactory();
fac.enable(BsonParser.Feature.HONOR_DOCUMENT_LENGTH);
BsonParser parser = (BsonParser)fac.createJsonParser(...);

Apart from that, a lot of other minor bugs have been fixed. The lib­rary has been tested with Jack­son 1.7 up to 1.9.

More information

For a com­plete de­scrip­tion of bson4­jack­son (in­clud­ing how to down­load it) have a look at my tu­torial.


Posted by Michel Krämer
on December, 17th 2011.


Next post

bson4jackson 2.0 has just been released!

Ver­sion 2.0 of bson4­jack­son has just been re­leased. bson4­jack­son adds sup­port for BSON, a bin­ary rep­res­ent­a­tion of JSON, to the Jack­son JSON pro­cessor. The…

Previous post

Build Scala projects with Eclipse Buckminster

In one of my pre­vi­ous posts I talked about how to build Scala pro­jects with PDE Build. However, PDE Build is rather old and has long been su­per­seded by…

Related posts

Binary JSON with bson4jackson

Re­cently, JSON has be­come an ex­cel­lent al­tern­at­ive to XML. But most JSON pars­ers writ­ten in Java are still rather slow. On my search for faster lib­rar­ies I found two…

bson4jackson 2.11.0

I’m de­lighted to an­nounce a new ver­sion of bson4­jack­son 2.11.0. The lib­rary is already very stable and there haven’t been many up­dates re­cently. The latest ver­sion…

bson4jackson 2.9.2

It’s been a while since I pos­ted up­dates on bson4­jack­son here on this blog, so now that ver­sion 2.9.2 has just been re­leased, I figured it would be a good idea…


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK