其中accident是java实体。
Gson gson = new Gson();
1、实体转json
JSONObject jsonObject = JSON.parse(gson.toJson(accident));
2、实体转mongo的DBObject
DBObject dbObject = (DBObject) JSON.parse(gson.toJson(accident));
其中accident是java实体。
Gson gson = new Gson();
1、实体转json
JSONObject jsonObject = JSON.parse(gson.toJson(accident));
2、实体转mongo的DBObject
DBObject dbObject = (DBObject) JSON.parse(gson.toJson(accident));