use of com.massivecraft.massivecore.xlib.gson.JsonObject in project MassiveCore by MassiveCraft.
the class GsonMongoConverter method mongo2GsonObject.
public static JsonObject mongo2GsonObject(DBObject inObject) {
if (!(inObject instanceof BasicDBObject))
throw new IllegalArgumentException("Expected BasicDBObject as argument type!");
BasicDBObject in = (BasicDBObject) inObject;
JsonObject jsonObject = new JsonObject();
for (Entry<String, Object> entry : in.entrySet()) {
String key = mongo2GsonKey(entry.getKey());
Object val = entry.getValue();
if (val instanceof BasicDBList) {
jsonObject.add(key, mongo2GsonArray((BasicDBList) val));
} else if (val instanceof BasicDBObject) {
jsonObject.add(key, mongo2GsonObject((BasicDBObject) val));
} else {
jsonObject.add(key, mongo2GsonPrimitive(val));
}
}
return jsonObject;
}
Aggregations