Package com.google.gson

Examples of com.google.gson.JsonObject.entrySet()


    @Override
    public SetMultimap<String, V> deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
        SetMultimap<String, V> result = HashMultimap.create();
        JsonObject obj = json.getAsJsonObject();
        for (Map.Entry<String, JsonElement> entry : obj.entrySet()) {
            if (entry.getValue().isJsonArray()) {
                for (JsonElement item : entry.getValue().getAsJsonArray()) {
                    result.put(entry.getKey(), context.<V>deserialize(item, valueType));
                }
            } else {
View Full Code Here


                metadata.shader = obj.getAsJsonPrimitive("shader").getAsString();
            }

            if (obj.has("params") && obj.get("params").isJsonObject()) {
                JsonObject params = obj.get("params").getAsJsonObject();
                for (Map.Entry<String, JsonElement> prop : params.entrySet()) {
                    if (prop.getValue().isJsonPrimitive()) {
                        if (prop.getValue().getAsJsonPrimitive().isString()) {
                            Texture texture = Assets.getTexture(prop.getValue().getAsString());
                            if (texture != null) {
                                metadata.textures.put(prop.getKey(), texture);
View Full Code Here

    private static class ComponentBuilderHandler implements JsonDeserializer<EntityData.Component.Builder> {
        @Override
        public EntityData.Component.Builder deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
            EntityData.Component.Builder component = EntityData.Component.newBuilder();
            JsonObject jsonObject = json.getAsJsonObject();
            for (Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) {
                EntityData.NameValue.Builder nameValue = EntityData.NameValue.newBuilder();
                nameValue.setName(entry.getKey());
                EntityData.Value value = context.deserialize(entry.getValue(), EntityData.Value.class);
                nameValue.setValue(value);
                component.addField(nameValue);
View Full Code Here

        @Override
        public EntityData.Entity deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
            EntityData.Entity.Builder entity = EntityData.Entity.newBuilder();
            JsonObject jsonObject = json.getAsJsonObject();

            for (Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) {
                String name = entry.getKey().toLowerCase(Locale.ENGLISH);
                switch (name) {
                    case "parentprefab":
                        if (entry.getValue().isJsonPrimitive()) {
                            entity.setParentPrefab(entry.getValue().getAsString());
View Full Code Here

        @Override
        public EntityData.Prefab deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
            EntityData.Prefab.Builder prefab = EntityData.Prefab.newBuilder();
            JsonObject jsonObject = json.getAsJsonObject();

            for (Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) {
                String name = entry.getKey().toLowerCase(Locale.ENGLISH);
                switch (name) {
                    case "name":
                        if (entry.getValue().isJsonPrimitive()) {
                            prefab.setName(entry.getValue().getAsString());
View Full Code Here

            return value.build();
        }

        private void extractMap(JsonElement json, JsonDeserializationContext context, EntityData.Value.Builder value) {
            JsonObject nameValueObject = json.getAsJsonObject();
            for (Map.Entry<String, JsonElement> nameValue : nameValueObject.entrySet()) {
                EntityData.Value innerValue = context.deserialize(nameValue.getValue(), EntityData.Value.class);
                value.addNameValue(EntityData.NameValue.newBuilder().setName(nameValue.getKey()).setValue(innerValue));
            }
        }
View Full Code Here

      return null;
    }
    JsonObject js = elem.getAsJsonObject();
    Type valueType = (type instanceof ParameterizedType) ? ((ParameterizedType) type).getActualTypeArguments()[1] : Object.class;
    Map<String, Object> map = JSCollections.$map();
    for (java.util.Map.Entry<String, JsonElement> entry : js.entrySet()) {
      map.$put(entry.getKey(), ctx.deserialize(entry.getValue(), valueType));
    }

    return map;
  }
View Full Code Here

  }

  @Override public void beginObject() throws IOException {
    expect(JsonToken.BEGIN_OBJECT);
    JsonObject object = (JsonObject) peekStack();
    stack.add(object.entrySet().iterator());
  }

  @Override public void endObject() throws IOException {
    expect(JsonToken.END_OBJECT);
    popStack(); // empty iterator
View Full Code Here

        JsonArray array = json.getAsJsonArray();
        Iterator<JsonElement> it = array.iterator();
        ArrayList<T> cmds = new ArrayList<T>();
        while (it.hasNext()) {
            JsonObject element = (JsonObject)it.next();
            Map.Entry<String, JsonElement> entry = element.entrySet().iterator().next();

            String name = entry.getKey();
            Class<?> clazz;
            try {
                clazz = Class.forName(name);
View Full Code Here

        public Map deserialize(JsonElement src, Type srcType, JsonDeserializationContext context) throws JsonParseException {

            Map<String, String> obj = new HashMap<String, String>();
            JsonObject json = src.getAsJsonObject();

            for (Entry<String, JsonElement> entry : json.entrySet()) {
                obj.put(entry.getKey(), entry.getValue().getAsString());
            }

            return obj;
        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.