Hi,
as discussed on https://groups.google.com/d/msg/mongodb-user/ihCV6zWzWlg/u7Q-AKxBEQEJ
The old "Json" package doesn't support the Extended JSON :
$type is not a String but an Integer
You can reproduce the problem with :
final Document document = new Document("test", new BsonBinary("test".getBytes()));
final String json = document.toJson();
System.out.println(json);
JSON.parse(json);
and you got :
{ "test" :
}
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
at com.mongodb.util.JSONCallback.objectDone(JSONCallback.java:127)
at com.mongodb.util.JSONParser.parseObject(JSON.java:274)
at com.mongodb.util.JSONParser.parse(JSON.java:227)
at com.mongodb.util.JSONParser.parseObject(JSON.java:263)
at com.mongodb.util.JSONParser.parse(JSON.java:227)
at com.mongodb.util.JSONParser.parse(JSON.java:155)
at com.mongodb.util.JSON.parse(JSON.java:92)
at com.mongodb.util.JSON.parse(JSON.java:73)
($type, as I understand, must be an Integer but Extended JSon ask for a String)