converting Document objects in MongoDB 3 to POJOS

后端 未结 4 973
攒了一身酷
攒了一身酷 2020-12-11 01:36

I\'m saving an object with a java.util.Date field into a MongoDB 3.2 instance.

ObjectMapper mapper = new ObjectMapper();
String json = mapper.writeValueAsStr         


        
4条回答
  •  佛祖请我去吃肉
    2020-12-11 02:15

    This looks like Mongo Java driver bug, where Document.toJson profuces non-standard JSON even if JsonMode.STRICT is used. This problem is described in the following bug https://jira.mongodb.org/browse/JAVA-2173 for which I encourage you to vote.

    A workaround is to use com.mongodb.util.JSON.serialize(document).

提交回复
热议问题