Package com.google.gson

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


      in = new FileReader(file);
      JsonStreamParser parser = new JsonStreamParser(in);
      JsonObject obj = (JsonObject)parser.next();

      Preferences preferences = getPreferences();
      for (Map.Entry<String,JsonElement> entry : obj.entrySet()){
        String name = entry.getKey();
        String value = entry.getValue().getAsString();
        try{
          preferences.setValue(name, value);
        }catch(IllegalArgumentException iae){
View Full Code Here


      in = new FileReader(file);
      JsonStreamParser parser = new JsonStreamParser(in);
      JsonObject obj = (JsonObject)parser.next();

      Preferences preferences = getPreferences();
      for (Map.Entry<String,JsonElement> entry : obj.entrySet()){
        String name = entry.getKey();
        String value = entry.getValue().getAsString();
        try{
          preferences.setValue(project, name, value);
        }catch(IllegalArgumentException iae){
View Full Code Here

      }

      if (relData != null) {

        for (Entry<String, JsonElement> entry : relData.entrySet()) {

          JsonElement obj = entry.getValue();
          webSocketData.setRelData(entry.getKey(), obj instanceof JsonNull ? null : obj.getAsString());
        }
View Full Code Here

    JsonInput wrapper = new JsonInput();
    if (json.isJsonObject()) {
      JsonObject obj = json.getAsJsonObject();

      for (Entry<String, JsonElement> entry : obj.entrySet()) {

        String key       = entry.getKey();
        JsonElement elem = entry.getValue();

        // static mapping of IdProperty if present
View Full Code Here

        log.error("Critical error reading from a world generation file: " + genFile + " > Please be sure the file is correct!", t);
        continue;
      }
      boolean saveFile = false;
      log.warn("Checking if " + genFile.getName() + " is from an old version.");
      for (Iterator<Entry<String, JsonElement>> iter = genList.entrySet().iterator(); iter.hasNext();) {
        Entry<String, JsonElement> genEntry = iter.next();

        JsonObject genObject = genEntry.getValue().getAsJsonObject();
        String templateName = parseTemplate(genObject);
        if ("uniform".equals(templateName) || "normal".equals(templateName)) {
View Full Code Here

        log.error("Critical error reading from a world generation file: " + genFile + " > Please be sure the file is correct!", t);
        continue;
      }

      log.info("Reading world generation info from: " + genFile + ":");
      for (Entry<String, JsonElement> genEntry : genList.entrySet()) {
        try {
          if (parseGenerationEntry(genEntry.getKey(), genEntry.getValue())) {
            log.debug("Generation entry successfully parsed: \"" + genEntry.getKey() + "\"");
          } else {
            log.error("Error parsing generation entry: \"" + genEntry.getKey() + "\" > Please check the parameters. It *may* be a duplicate.");
View Full Code Here

  @Override
  public void execute(Message message) throws Exception {
    String body = (String) message.getProperty("body");
    JsonObject jsonObject = new JsonParser().parse(body).getAsJsonObject();
    Set<Map.Entry<String, JsonElement>> jsonEntrySet = jsonObject.entrySet();
    for (Map.Entry<String, JsonElement> jsonEntry : jsonEntrySet) {
      message.setProperty(jsonEntry.getKey(), jsonEntry.getValue().getAsString());
    }
  }
}
View Full Code Here

  @Override
  public Annotation deserialize(JsonElement json, Type typeOfT,
      JsonDeserializationContext context) throws JsonParseException {
   
    JsonObject o = json.getAsJsonObject();
    Set<Entry<String,JsonElement>> entrySet = o.entrySet();
    if (entrySet.size() != 1) {
      throw new JsonParseException("Annotation type with more than one property?");
    }

    Entry<String,JsonElement> kv = entrySet.iterator().next();
View Full Code Here

        jsonObject.get(RequestProperty.ID.key()).getAsString(),
        getPropertyAsStringThenRemove(parameters, ParamsProperty.WAVE_ID),
        getPropertyAsStringThenRemove(parameters, ParamsProperty.WAVELET_ID),
        getPropertyAsStringThenRemove(parameters, ParamsProperty.BLIP_ID));

    for (Entry<String, JsonElement> parameter : parameters.entrySet()) {
      ParamsProperty parameterType = ParamsProperty.fromKey(parameter.getKey());
      if (parameterType != null) {
        Object object = ctx.deserialize(parameter.getValue(), parameterType.clazz());
        request.addParameter(Parameter.of(parameterType, object));
      }
View Full Code Here

        @Override
        public BindsConfig deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
            BindsConfig result = new BindsConfig();
            JsonObject inputObj = json.getAsJsonObject();
            for (Map.Entry<String, JsonElement> entry : inputObj.entrySet()) {
                SetMultimap<String, Input> map = context.deserialize(entry.getValue(), SetMultimap.class);
                for (String id : map.keySet()) {
                    SimpleUri uri = new SimpleUri(new Name(entry.getKey()), id);
                    result.data.putAll(uri, map.get(id));
                }
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.