Package com.google.gson

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


        } else if (o instanceof JsonElement) {
            // JsonElement json = (JsonElement) o;
            if (o instanceof JsonObject) {
                JsonObject json = (JsonObject) o;
                protobuf.beginObject();
                for (Entry<String, JsonElement> entry : json.entrySet()) {
                    protobuf.name(entry.getKey());
                    write(entry.getValue());
                }
                protobuf.endObject();
            } else if (o instanceof JsonPrimitive) {
View Full Code Here


                }
            }
            if (classInstance == null)
            {
                Map<String, Object> result = new HashMap<String, Object>();
                for (Map.Entry<String, JsonElement> entry : object.entrySet())
                {
                    Object value = context.deserialize(entry.getValue(), Object.class);
                    result.put(entry.getKey(), value);
                }
                return new SimplePropertyValue(result);
View Full Code Here

      else if( jsonValue.isJsonObject() ) {
        //This simply does not work (?)
        //value = getGson().fromJson(jsonValue, Map.class );

        JsonObject obj = jsonValue.getAsJsonObject();
        Iterator<Entry<String,JsonElement>> properties = obj.entrySet().iterator();
        Map<String, Object> result = new HashMap<String,Object>();
        while( properties.hasNext() ) {
          Entry<String,JsonElement> property = properties.next();
          JsonElement propertyValue = property.getValue();
          result.put( property.getKey(), toSimpleJavaType(propertyValue))
View Full Code Here

              appType.setTypePackageFileName(appZip.getName());
              // Configs
              Map<String, String> configsMap = new HashMap<String, String>();
              JsonObject appTypeGlobalJson = appConfigJson.getAsJsonObject()
                  .get("global").getAsJsonObject();
              for (Entry<String, JsonElement> e : appTypeGlobalJson.entrySet()) {
                configsMap.put(e.getKey(), e.getValue().getAsString());
              }
              appType.setTypeConfigs(configsMap);
              // Components
              ArrayList<SliderAppTypeComponent> appTypeComponentList = new ArrayList<SliderAppTypeComponent>();
View Full Code Here

          // desired configs
          Map<String, String> desiredConfigs = new HashMap<String, String>();
          JsonObject desiredConfigsObj = jsonElement.getAsJsonObject()
              .get("Clusters").getAsJsonObject().get("desired_configs")
              .getAsJsonObject();
          for (Map.Entry<String, JsonElement> entry : desiredConfigsObj
              .entrySet()) {
            desiredConfigs.put(entry.getKey(), entry.getValue()
                .getAsJsonObject().get("tag").getAsString());
          }
          cluster.setDesiredConfigs(desiredConfigs);
View Full Code Here

        JsonArray configsArray = jsonObject.get("items").getAsJsonArray();
        if (configsArray.size() > 0) {
          JsonObject propertiesObj = configsArray.get(0).getAsJsonObject()
              .get("properties").getAsJsonObject();
          Map<String, String> properties = new HashMap<String, String>();
          for (Map.Entry<String, JsonElement> entry : propertiesObj.entrySet()) {
            properties.put(entry.getKey(), entry.getValue().getAsString());
          }
          return properties;
        }
      } catch (HttpException e) {
View Full Code Here

      Map<String, String> quickLinks = new HashMap<String, String>();
      if (json != null && json.getAsJsonObject() != null
          && json.getAsJsonObject().has("entries")) {
        JsonObject jsonObject = json.getAsJsonObject().get("entries")
            .getAsJsonObject();
        for (Entry<String, JsonElement> entry : jsonObject.entrySet()) {
          if ("org.apache.slider.jmx".equals(entry.getKey())) {
            quickLinks.put("JMX", entry.getValue().getAsString());
          } else if ("org.apache.slider.monitor".equals(entry.getKey())) {
            quickLinks.put("UI", entry.getValue().getAsString());
          } else if ("org.apache.slider.metrics".equals(entry.getKey())) {
View Full Code Here

      Map<String, Map<String, String>> configsMap = new HashMap<String, Map<String, String>>();
      JsonElement json = super.doGetJson(providerUrl, "/slider");
      if (json != null) {
        JsonObject configsJson = json.getAsJsonObject().get("configurations")
            .getAsJsonObject();
        for (Entry<String, JsonElement> entry : configsJson.entrySet()) {
          if ("complete-config".equals(entry.getKey())
              || "quicklinks".equals(entry.getKey())) {
            continue;
          }
          JsonElement entryJson = super.doGetJson(providerUrl, "/slider/"
View Full Code Here

          if (entryJson != null) {
            JsonObject configsObj = entryJson.getAsJsonObject().get("entries")
                .getAsJsonObject();
            if (configsObj != null) {
              Map<String, String> configs = new HashMap<String, String>();
              for (Entry<String, JsonElement> e : configsObj.entrySet()) {
                configs.put(e.getKey(), e.getValue().getAsString());
              }
              configsMap.put(entry.getKey(), configs);
            }
          }
View Full Code Here

    }

    private static void recursiveParse(JsonElement jse, Element element) {
        if (jse.isJsonObject()) {
          JsonObject j = jse.getAsJsonObject();
          Set<Entry<String, JsonElement>> set = j.entrySet();
//          System.out.println(set.size());
            Iterator<Entry<String, JsonElement>> iter = set.iterator();
            while (iter.hasNext()) {
              Entry<String, JsonElement> entry = iter.next();
             
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.