bguerout/jongo

BigDecimal is serialized incorrectly

Closed this issue · 1 comments

BigDecimal with floating point is serialized to json incorrectly with JacksonMapper.
If I use pure fasterxml new ObjectMapper() json is produced correctly.

        Document doc = new Document();
        doc.put("BigDecimal", new BigDecimal(1.099d));
        doc.put("Double", 1.099d);
        Mapper mapper = new JacksonMapper.Builder().build();
        Jongo jongo = new Jongo(db, mapper);
        MongoCollection collection = jongo.getCollection("bd.test");
        collection.insert(doc);

results in
{ "_id" : ObjectId("576ae1e0ceb5a93d06bf4991"), "BigDecimal" : 1.09899997711182, "Double" : 1.099, }

There is no SerializationFeature available to control how BigDecimal is serialized to json

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.