有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!


共 (1) 个答案

  1. # 1 楼答案

    您可以获取bson对象并对其调用toJson(),以获取包含json格式的查询结果的字符串。这应该允许您使用Jsoniter或Gson来反序列化查询结果

    例如:

    Document result = collection.find(eq("birthYear", 1990)).first(); // Made up query
    String resultJsonString = result.toJson();
    

    您可以在the MongoDB documentation for the Java DB Driver中阅读有关toJson()方法的更多信息