I am using Mongo driver for java 3.2.2 and trying to convert the bson document to valid java object. When I am using the below java code :
Document value = (Document)dataObject.get(VALUE);
Gson gson = new Gson();
CustomClasss classObject = gson.fromJson(value.toJson(),CustomClass.class);
I am getting the exception while conversion. This exception is due to date and long fields in the value document above. While converting I am getting the extra
$date and $numberlong
fields from
value.toJson()
Any suggestions how I can do this conversion.
Thanks in Advance,
Amandeep