Search in sources :

Example 6 with JsonArray

use of com.massivecraft.massivecore.xlib.gson.JsonArray in project MassiveCore by MassiveCraft.

the class GsonMongoConverter method mongo2GsonArray.

public static JsonArray mongo2GsonArray(DBObject inObject) {
    if (!(inObject instanceof BasicDBList))
        throw new IllegalArgumentException("Expected BasicDBList as argument type!");
    BasicDBList in = (BasicDBList) inObject;
    JsonArray jsonArray = new JsonArray();
    for (int i = 0; i < in.size(); i++) {
        Object object = in.get(i);
        if (object instanceof BasicDBList) {
            jsonArray.add(mongo2GsonArray((BasicDBList) object));
        } else if (object instanceof BasicDBObject) {
            jsonArray.add(mongo2GsonObject((BasicDBObject) object));
        } else {
            jsonArray.add(mongo2GsonPrimitive(object));
        }
    }
    return jsonArray;
}
Also used : JsonArray(com.massivecraft.massivecore.xlib.gson.JsonArray) BasicDBList(com.massivecraft.massivecore.xlib.mongodb.BasicDBList) BasicDBObject(com.massivecraft.massivecore.xlib.mongodb.BasicDBObject) JsonObject(com.massivecraft.massivecore.xlib.gson.JsonObject) DBObject(com.massivecraft.massivecore.xlib.mongodb.DBObject) BasicDBObject(com.massivecraft.massivecore.xlib.mongodb.BasicDBObject)

Aggregations

JsonArray (com.massivecraft.massivecore.xlib.gson.JsonArray)6 JsonElement (com.massivecraft.massivecore.xlib.gson.JsonElement)4 JsonObject (com.massivecraft.massivecore.xlib.gson.JsonObject)2 BasicDBList (com.massivecraft.massivecore.xlib.mongodb.BasicDBList)2 ParameterizedType (java.lang.reflect.ParameterizedType)2 Type (java.lang.reflect.Type)2 MassiveListDef (com.massivecraft.massivecore.collections.MassiveListDef)1 DataBannerPattern (com.massivecraft.massivecore.item.DataBannerPattern)1 JsonNull (com.massivecraft.massivecore.xlib.gson.JsonNull)1 BasicDBObject (com.massivecraft.massivecore.xlib.mongodb.BasicDBObject)1 DBObject (com.massivecraft.massivecore.xlib.mongodb.DBObject)1 SimpleEntry (java.util.AbstractMap.SimpleEntry)1