Package com.google.gson

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


    }

    if (entry.has(RESPONSE_HEADERS)) {
      JsonObject jsonHeaders = entry.get(RESPONSE_HEADERS).getAsJsonObject();
      ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
      for (Entry<String, JsonElement> jsonEntry : jsonHeaders.entrySet()) {
        builder.put(jsonEntry.getKey(), jsonEntry.getValue().getAsString());
      }
      responseHeaders = builder.build();
    }
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

        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

    @Override
    @SuppressWarnings("unchecked")
    public T deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
        JsonObject element = (JsonObject)json;
        Map.Entry<String, JsonElement> entry = element.entrySet().iterator().next();
        String name = entry.getKey();
        Class<?> clazz;
        try {
            clazz = Class.forName(name);
        } catch (ClassNotFoundException e) {
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 = s_pkg + 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

            if (!arg0.isJsonObject()) {
                throw new JsonParseException(arg0.toString() + " is not Json Object, cannot convert to map");
            }
            JsonObject objs = arg0.getAsJsonObject();
            Map<String, String> map = new HashMap<String, String>();
            for (Entry<String, JsonElement> e : objs.entrySet()) {
                if (!e.getValue().isJsonPrimitive()) {
                    throw new JsonParseException(e.getValue().toString() + " is not a Json primitive," + arg0 + " can not convert to map");
                }
                map.put(e.getKey(), e.getValue().getAsString());
            }
View Full Code Here

        Map<String, MCInjectorStruct> ret = new LinkedHashMap<String, MCInjectorStruct>();

        JsonObject object = (JsonObject)new JsonParser().parse(reader);
        reader.close();

        for (Entry<String, JsonElement> entry : object.entrySet())
        {
            ret.put(entry.getKey(), GSON.fromJson(entry.getValue(), MCInjectorStruct.class));
        }
        return ret;
    }
View Full Code Here

            obj.artifacts = new LinkedList<Artifact>();
           
            JsonObject groupLevel = json.getAsJsonObject().getAsJsonObject("artefacts");
           
            // itterate over the groups
            for (Entry<String, JsonElement> groupE : groupLevel.entrySet())
            {
                String group = groupE.getKey();
               
                // itterate over the artefacts in the groups
                for (Entry<String, JsonElement> artifactE : groupE.getValue().getAsJsonObject().entrySet())
View Full Code Here

        return enforceTypeNamingPolicy(jaje, nDepth + 1); // keep going until you find primitive/object
      }
      else if (je.isJsonObject()) {
        JsonObject jo = je.getAsJsonObject();
        // Nested variables:
        Iterator<Entry<String, JsonElement>> it = jo.entrySet().iterator();
        Map<String, JsonElement> toFixList = null;
        while (it.hasNext()) {
          boolean bFix = false;
          Entry<String, JsonElement> el = it.next();
          String currKey = el.getKey();
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.