Gson gson = new Gson(); String str = "list集合json字符串";
JsonObject object = gson.fromJson(str, JsonObject.class);
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));
如有更好的方法欢迎指点