Gson gson = new Gson();

      String str = "list集合json字符串";
);
            List<实体> t = gson.fromJson("字符串",
                    new TypeToken<List<实体>>() {
                    }.getType());
            BasicDBList basicDBList = (BasicDBList) JSON.parse(gson.toJson(t));
            DBObject object2 = new BasicDBObject("list", basicDBList);
            List<DBObject> list = (List<DBObject>) object2.get("list");

 单个对象的:

      Gson gson = new Gson();
            实体 t = gson.fromJson("json字符串",
                    实体.class);
            DBObject object = (DBObject) JSON.parse(gson.toJson(t));

 

如有更好的方法欢迎指点

 

相关文章:

  • 2022-12-23
  • 2021-12-13
  • 2021-10-08
  • 2022-12-23
  • 2021-09-27
  • 2021-07-22
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2018-08-09
  • 2021-07-29
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案