Java http://blog.locut.us/main/2009/10/14/which-is-the-best-java-json-library.htmlでJSONを適切にサポートしていますが、BSONについてはどうでしょうか。
JavaのBSONサポートを提供するライブラリを知っていますか?実行時に明らかに効率的であるはずです。
Java http://blog.locut.us/main/2009/10/14/which-is-the-best-java-json-library.htmlでJSONを適切にサポートしていますが、BSONについてはどうでしょうか。
JavaのBSONサポートを提供するライブラリを知っていますか?実行時に明らかに効率的であるはずです。
You can use the MongoDB driver for Java to store a BSON object, then convert that to a String
which you can then wrap with JSONObject
.
For example, here's how I'll create a regular document:
BasicDBObject obj = new BasicDBObject();
obj.put("name", "Matt");
obj.put("date", new Date());
Then, to get a String
representation of the object, simply call:
String bsonString = obj.toString();
Wrap it with a JSONObject
and get the date attribute, which should return it in a BSON-compliant format.
JSONObject newObject = new JSONObject(bsonString);
System.out.println(newObject.get("date"));
The resulting output is something like:
{"$date":"2012-08-10T05:22:53.872Z"}
MongoDB から使用する場合は、この例を見てください。
MongoDB でモデルを取得するために、最初に Google gson を使用してモデルを JSON に変換し、次にMongoDB の JSON util parse メソッドを使用して、生成された JSON 文字列を解析し、MongoDB に配置できる DBObject に変換しました。性能は正直言ってわかりません。
エブソンもあります。私はそれを試していない...
また、かなり新しいBSON4Jacksonプロジェクトもあり、 Jacksonを使用して BSON データを処理できます。これは、完全なデータ バインディング (POJO との間)、ツリー モデル、さらにはストリーミング (増分) 読み取り/書き込みを BSON 形式で実行できることを意味します。