コード例 #1
0
 public Map<K, V> a(JsonReader paramJsonReader) throws IOException {
   Object localObject = paramJsonReader.peek();
   if (localObject == JsonToken.NULL) {
     paramJsonReader.nextNull();
     return null;
   }
   Map localMap = (Map) d.a();
   if (localObject == JsonToken.BEGIN_ARRAY) {
     paramJsonReader.beginArray();
     while (paramJsonReader.hasNext()) {
       paramJsonReader.beginArray();
       localObject = b.b(paramJsonReader);
       if (localMap.put(localObject, c.b(paramJsonReader)) != null) {
         throw new JsonSyntaxException("duplicate key: " + localObject);
       }
       paramJsonReader.endArray();
     }
     paramJsonReader.endArray();
     return localMap;
   }
   paramJsonReader.beginObject();
   while (paramJsonReader.hasNext()) {
     d.INSTANCE.promoteNameToValue(paramJsonReader);
     localObject = b.b(paramJsonReader);
     if (localMap.put(localObject, c.b(paramJsonReader)) != null) {
       throw new JsonSyntaxException("duplicate key: " + localObject);
     }
   }
   paramJsonReader.endObject();
   return localMap;
 }
コード例 #2
0
  private Dependency readDependency(JsonReader in) throws IOException {
    DefaultDependency dep = new DefaultDependency();

    in.beginObject();
    while (in.hasNext()) {
      String name = in.nextName();
      switch (name) {
        case PACKAGE_PROPERTY:
          dep.setPackage(in.nextString());
          break;
        case VERSION_PROPERTY:
          dep.setVersion(in.nextString());
          break;
        case DEPENDNCY_OP_PROPERTY:
          dep.setDependencyOperator(RelationOperator.valueOf(in.nextString()));
          break;
        case ALTERNATIVES_PROPERTY:
          in.beginArray();
          while (in.hasNext()) {
            dep.getAlternatives().add(readDependency(in));
          }
          in.endArray();
          break;
        default:
          in.skipValue();
          break;
      }
    }
    in.endObject();

    return dep;
  }
コード例 #3
0
 public static Set<String> fromString(String str) {
   TreeSet<String> result = new TreeSet<String>();
   if (str == null || str.isEmpty()) {
     return result;
   }
   try {
     JsonReader reader = new JsonReader(new StringReader(str));
     reader.beginObject();
     while (reader.hasNext()) {
       String key = reader.nextName();
       if (JSON_STARRED_SESSIONS_KEY.equals(key)) {
         reader.beginArray();
         while (reader.hasNext()) {
           result.add(reader.nextString());
         }
         reader.endArray();
       } else {
         reader.skipValue();
       }
     }
     reader.endObject();
     reader.close();
   } catch (Exception ex) {
     Log.w(TAG, "Ignoring invalid remote content.", ex);
     return null;
   }
   return result;
 }
コード例 #4
0
  private int importFile(File importPath, ImporterExporter importer) {
    File file = new File(importPath, importer.getFileName());
    if (!file.exists() || !file.canRead()) {
      return ERROR_FILE_ACCESS;
    }

    importer.initializeImport(mContext);

    try {
      InputStream in = new FileInputStream(file);

      Gson gson = new Gson();

      JsonReader reader = new JsonReader(new InputStreamReader(in, "UTF-8"));
      reader.beginArray();

      while (reader.hasNext()) {
        importer.importRecord(mContext, gson, reader);
      }

      reader.endArray();
      reader.close();
    } catch (JsonParseException | IOException e) {
      // the given Json might not be valid or unreadable
      Timber.e(e, "JSON show import failed");
      return ERROR;
    }

    return SUCCESS;
  }
コード例 #5
0
ファイル: QuestAdapter.java プロジェクト: Bunsan/HQM
 private ItemStack[] readItemStackArray(JsonReader in) throws IOException {
   List<ItemStack> stacks = new ArrayList<>();
   in.beginArray();
   while (in.hasNext()) {
     ItemStack stack = MinecraftAdapter.ITEM_STACK.read(in);
     if (stack != null) stacks.add(stack);
   }
   in.endArray();
   return stacks.toArray(new ItemStack[stacks.size()]);
 }
コード例 #6
0
    @Override
    public TimeSeries<Location> read(JsonReader in) throws IOException {
      if (gson == null) {
        gson = Vinli.curApp().gson();
      }

      final TimeSeries.Builder<Location> b =
          new AutoParcel_TimeSeries.Builder<Location>().type(TIME_SERIES_TYPE);

      in.beginObject();
      while (in.hasNext()) {
        final String name = in.nextName();

        switch (name) {
          case "meta":
            b.meta(gson.<TimeSeries.Meta>fromJson(in, TimeSeries.Meta.class));
            break;
          case "locations":
            in.beginObject();
            while (in.hasNext()) {
              final String locName = in.nextName();

              switch (locName) {
                case "type":
                  in.skipValue();
                  break;
                case "features":
                  final List<Location> locations = new ArrayList<>();

                  in.beginArray();
                  while (in.hasNext()) {
                    locations.add(gson.<Location>fromJson(in, Location.class));
                  }
                  in.endArray();

                  b.items(locations);
                  break;
                default:
                  throw new JsonParseException(
                      "unrecognized key '" + locName + "' while parsing locations");
              }
            }
            in.endObject();
            break;
          default:
            throw new JsonParseException("unrecognized key '" + name + "' while parsing locations");
        }
      }
      in.endObject();

      return b.build();
    }
コード例 #7
0
 @Override
 public void consume(JsonReader in, JsonSchemaObject object) throws IOException {
   if (in.peek() == JsonToken.BEGIN_ARRAY) {
     in.beginArray();
     final ArrayList<JsonSchemaObject> list = new ArrayList<>();
     while (in.peek() != JsonToken.END_ARRAY) {
       if (in.peek() == JsonToken.BEGIN_OBJECT) {
         list.add(readInnerObject(in));
       } else in.skipValue();
     }
     assign(list, object);
     in.endArray();
   } else in.skipValue();
 }
コード例 #8
0
    public Collection<E> read(JsonReader in) throws IOException {
      if (in.peek() == JsonToken.NULL) {
        in.nextNull();
        return null;
      }

      Collection<E> collection = constructor.construct();
      in.beginArray();
      while (in.hasNext()) {
        E instance = elementTypeAdapter.read(in);
        collection.add(instance);
      }
      in.endArray();
      return collection;
    }
コード例 #9
0
 @Override
 protected Object parseValue(JsonReader reader, String name) throws Exception {
   switch (JsonValues.valueOf(name)) {
     case patterns:
       this.patterns = new ArrayList<>();
       reader.beginArray();
       while (reader.peek() != JsonToken.END_ARRAY) {
         this.patterns.add(Pattern.compile(reader.nextString()));
       }
       reader.endArray();
       return this.patterns;
     default:
       return super.parseValue(reader, name);
   }
 }
コード例 #10
0
ファイル: QuestAdapter.java プロジェクト: Bunsan/HQM
 @Override
 public QuestSet read(JsonReader in) throws IOException {
   String name = null, description = null;
   requirementMapping.clear();
   optionMapping.clear();
   List<Quest> quests = new ArrayList<Quest>();
   in.beginObject();
   while (in.hasNext()) {
     String next = in.nextName();
     if (next.equalsIgnoreCase(NAME)) {
       name = in.nextString();
     } else if (next.equalsIgnoreCase(DESCRIPTION)) {
       description = in.nextString();
     } else if (next.equalsIgnoreCase(QUESTS)) {
       in.beginArray();
       QUEST_ID = Quest.size();
       while (in.hasNext()) {
         Quest quest = QUEST_ADAPTER.read(in);
         if (quest != null) {
           quests.add(quest);
         }
       }
       in.endArray();
     }
   }
   in.endObject();
   for (QuestSet set : Quest.getQuestSets()) {
     if (set.getName().equals(name)) {
       return removeQuests(quests);
     }
   }
   if (name != null && description != null) {
     QuestSet set = new QuestSet(name, description);
     Quest.getQuestSets().add(set);
     SaveHelper.add(SaveHelper.EditType.SET_CREATE);
     for (Quest quest : quests) {
       quest.setQuestSet(set);
     }
     for (Map.Entry<Quest, List<Integer>> entry : requirementMapping.entrySet()) {
       for (int i : entry.getValue()) entry.getKey().addRequirement(i);
     }
     for (Map.Entry<Quest, List<Integer>> entry : optionMapping.entrySet()) {
       for (int i : entry.getValue()) entry.getKey().addOptionLink(i);
     }
     return set;
   }
   return removeQuests(quests);
 }
コード例 #11
0
  private void getdata() throws IOException {

    // open URL for JSON parser:

    URL obj_URL = new URL(url);
    InputStream in = obj_URL.openStream();
    JsonReader reader = new JsonReader(new InputStreamReader(in, "UTF-8"));

    // read charge points array:

    reader.beginArray();
    while (!isCancelled() && reader.hasNext()) {
      ChargePoint chargePoint = gson.fromJson(reader, ChargePoint.class);
      chargePoints.add(chargePoint);
    }
    reader.endArray();
    reader.close();
  }
コード例 #12
0
  public ArrayList<Clientes> leerFlujoJson(InputStream in) throws IOException {
    // Nueva instancia de la clase Gson
    Gson gson = new Gson();

    JsonReader reader = new JsonReader(new InputStreamReader(in, "UTF-8"));
    ArrayList<Clientes> animales = new ArrayList<>();

    // Iniciar el array
    reader.beginArray();

    while (reader.hasNext()) {
      // Lectura de objetos
      Clientes cliente = gson.fromJson(reader, Clientes.class);
      animales.add(cliente);
    }

    reader.endArray();
    reader.close();
    return animales;
  }
コード例 #13
0
  /*
   * (non-Javadoc)
   *
   * @see com.google.gson.TypeAdapter#read(com.google.gson.stream.JsonReader)
   */
  @Override
  public SpeechTimestamp read(JsonReader reader) throws IOException {
    if (reader.peek() == JsonToken.NULL) {
      reader.nextNull();
      return null;
    }

    String word = null;
    Double startTime = null, endTime = null;

    reader.beginArray();

    if (reader.peek() == JsonToken.STRING) {
      word = reader.nextString();
    }
    if (reader.peek() == JsonToken.NUMBER) {
      startTime = reader.nextDouble();
    }
    if (reader.peek() == JsonToken.NUMBER) {
      endTime = reader.nextDouble();
    }

    reader.endArray();

    SpeechTimestamp speechTimestamp = new SpeechTimestamp();

    if (word != null) {
      speechTimestamp.setWord(word);
    }

    if (startTime != null) {
      speechTimestamp.setStartTime(startTime);
    }

    if (endTime != null) {
      speechTimestamp.setEndTime(endTime);
    }

    return speechTimestamp;
  }
コード例 #14
0
        public BitSet read(JsonReader in) throws IOException {
          if (in.peek() == JsonToken.NULL) {
            in.nextNull();
            return null;
          }

          BitSet bitset = new BitSet();
          in.beginArray();
          int i = 0;
          JsonToken tokenType = in.peek();
          while (tokenType != JsonToken.END_ARRAY) {
            boolean set;
            switch (tokenType) {
              case NUMBER:
                set = in.nextInt() != 0;
                break;
              case BOOLEAN:
                set = in.nextBoolean();
                break;
              case STRING:
                String stringValue = in.nextString();
                try {
                  set = Integer.parseInt(stringValue) != 0;
                } catch (NumberFormatException e) {
                  throw new JsonSyntaxException(
                      "Error: Expecting: bitset number value (1, 0), Found: " + stringValue);
                }
                break;
              default:
                throw new JsonSyntaxException("Invalid bitset value type: " + tokenType);
            }
            if (set) {
              bitset.set(i);
            }
            ++i;
            tokenType = in.peek();
          }
          in.endArray();
          return bitset;
        }
コード例 #15
0
  public List<Map<String, Object>> parsePublicTimeline(InputStream inputStream) {

    List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();

    try {
      JsonReader reader = new JsonReader(new InputStreamReader(inputStream, "UTF-8"));

      reader.beginArray();
      while (reader.hasNext()) {
        Map<String, Object> map = new HashMap<String, Object>();

        reader.beginObject();
        while (reader.hasNext()) {
          String name = reader.nextName();
          if ("user".equals(name)) {
            reader.beginObject();
            while (reader.hasNext()) {
              String name2 = reader.nextName();
              map.put("user." + name2, getValue(reader));
            }
            reader.endObject();
          } else {
            map.put(name, getValue(reader));
          }
        }

        reader.endObject();

        result.add(map);
      }
      reader.endArray();

    } catch (Exception e) {
      e.printStackTrace();
    }

    return result;
  }
コード例 #16
0
 @Override
 public JsonElement read(JsonReader in) throws IOException {
   switch (in.peek()) {
     case STRING:
       return new JsonPrimitive(in.nextString());
     case NUMBER:
       String number = in.nextString();
       return new JsonPrimitive(new LazilyParsedNumber(number));
     case BOOLEAN:
       return new JsonPrimitive(in.nextBoolean());
     case NULL:
       in.nextNull();
       return JsonNull.INSTANCE;
     case BEGIN_ARRAY:
       JsonArray array = new JsonArray();
       in.beginArray();
       while (in.hasNext()) {
         array.add(read(in));
       }
       in.endArray();
       return array;
     case BEGIN_OBJECT:
       JsonObject object = new JsonObject();
       in.beginObject();
       while (in.hasNext()) {
         object.add(in.nextName(), read(in));
       }
       in.endObject();
       return object;
     case END_DOCUMENT:
     case NAME:
     case END_OBJECT:
     case END_ARRAY:
     default:
       throw new IllegalArgumentException();
   }
 }
コード例 #17
0
ファイル: JsonKadSerializer.java プロジェクト: tcxhb/openkad
  @Override
  public KadMessage read(final InputStream in)
      throws IOException, ClassCastException, ClassNotFoundException {
    Reader utf8Reader = null;
    JsonReader reader = null;

    KadMessage msg = null;
    try {
      utf8Reader = new InputStreamReader(in, "UTF-8");
      reader = new JsonReader(utf8Reader);

      reader.beginArray();
      final String clazzName = gson.fromJson(reader, String.class);
      msg = gson.fromJson(reader, Class.forName(classPackage + clazzName));
      reader.endArray();

    } finally {
      reader.close();
      utf8Reader.close();
      in.close();
    }

    return msg;
  }
コード例 #18
0
  private void jsonReadContElements(JsonReader jReader) throws IOException {
    jReader.beginObject();
    List<String> loadedLfs = new ArrayList<>();
    boolean exceptForDecimal5Raised = false;
    boolean enumChecked = false;
    boolean bitsChecked = false;
    boolean lfdecimal6Checked = false;
    boolean lfdecimal4Checked = false;
    boolean lfdecimal3Checked = false;
    boolean lfdecimal2Checked = false;
    boolean lfdecimal1Checked = false;
    boolean lfbool1Checked = false;
    boolean lfbool2Checked = false;
    boolean lfstrChecked = false;
    boolean lfbinaryChecked = false;
    // boolean lfref1Checked = false;
    boolean lfemptyChecked = false;
    boolean lfstr1Checked = false;

    while (jReader.hasNext()) {
      String keyName = jReader.nextName();
      JsonToken peek = null;
      try {
        peek = jReader.peek();
      } catch (IOException e) {
        if (keyName.equals("lfdecimal5")) {
          exceptForDecimal5Raised = true;
        } else {
          assertTrue("Key " + keyName + " has incorrect value for specifed type", false);
        }
      }

      if (keyName.startsWith("lfnint") || keyName.startsWith("lfnuint")) {
        assertEquals("Key " + keyName + " has incorrect type", JsonToken.NUMBER, peek);
        try {
          jReader.nextLong();
        } catch (NumberFormatException e) {
          assertTrue("Key " + keyName + " has incorrect value - " + e.getMessage(), false);
        }
        loadedLfs.add(keyName.substring(3));
      } else if (keyName.equals("lfstr")) {
        assertEquals("Key " + keyName + " has incorrect type", JsonToken.STRING, peek);
        assertEquals("lfstr", jReader.nextString());
        lfstrChecked = true;
      } else if (keyName.equals("lfstr1")) {
        assertEquals("Key " + keyName + " has incorrect type", JsonToken.STRING, peek);
        assertEquals("", jReader.nextString());
        lfstr1Checked = true;
      } else if (keyName.equals("lfbool1")) {
        assertEquals("Key " + keyName + " has incorrect type", JsonToken.BOOLEAN, peek);
        assertEquals(true, jReader.nextBoolean());
        lfbool1Checked = true;
      } else if (keyName.equals("lfbool2")) {
        assertEquals("Key " + keyName + " has incorrect type", JsonToken.BOOLEAN, peek);
        assertEquals(false, jReader.nextBoolean());
        lfbool2Checked = true;
      } else if (keyName.equals("lfbool3")) {
        assertEquals("Key " + keyName + " has incorrect type", JsonToken.BOOLEAN, peek);
        assertEquals(false, jReader.nextBoolean());
      } else if (keyName.equals("lfdecimal1")) {
        assertEquals("Key " + keyName + " has incorrect type", JsonToken.NUMBER, peek);
        assertEquals(new Double(43.32), (Double) jReader.nextDouble());
        lfdecimal1Checked = true;
      } else if (keyName.equals("lfdecimal2")) {
        assertEquals("Key " + keyName + " has incorrect type", JsonToken.NUMBER, peek);
        assertEquals(new Double(-0.43), (Double) jReader.nextDouble());
        lfdecimal2Checked = true;
      } else if (keyName.equals("lfdecimal3")) {
        assertEquals("Key " + keyName + " has incorrect type", JsonToken.NUMBER, peek);
        assertEquals(new Double(43), (Double) jReader.nextDouble());
        lfdecimal3Checked = true;
      } else if (keyName.equals("lfdecimal4")) {
        assertEquals("Key " + keyName + " has incorrect type", JsonToken.NUMBER, peek);
        assertEquals(new Double(43E3), (Double) jReader.nextDouble());
        lfdecimal4Checked = true;
      } else if (keyName.equals("lfdecimal6")) {
        assertEquals("Key " + keyName + " has incorrect type", JsonToken.NUMBER, peek);
        assertEquals(new Double(33.12345), (Double) jReader.nextDouble());
        lfdecimal6Checked = true;
      } else if (keyName.equals("lfenum")) {
        assertEquals("enum3", jReader.nextString());
        enumChecked = true;
      } else if (keyName.equals("lfbits")) {
        assertEquals("bit3", jReader.nextString());
        bitsChecked = true;
      } else if (keyName.equals("lfbinary")) {
        assertEquals(
            "AAaacdabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ%%-#^",
            jReader.nextString());
        lfbinaryChecked = true;
      } else if (keyName.equals("lfempty")) {
        jReader.beginArray();
        jReader.nextNull();
        jReader.endArray();
        lfemptyChecked = true;
      } else if (keyName.startsWith("lfunion")) {
        checkLfUnion(jReader, keyName, peek);
      } else {
        assertTrue("Key " + keyName + " doesn't exists in yang file.", false);
      }
    }
    Collections.sort(loadedLfs);
    String expectedLfsStr =
        "[int16Max, int16Min, int32Max, int32Min, int64Max, int64Min, int8Max, int8Min, uint16Max, uint32Max, uint8Max]";
    String actualLfsStr = loadedLfs.toString();
    assertEquals("Some leaves are missing", expectedLfsStr, actualLfsStr);
    // assertTrue("For lfdecimal5 wasn't catch error",exceptForDecimal5Raised);
    assertTrue("Enum wasn't checked", enumChecked);
    assertTrue("Bits wasn't checked", bitsChecked);
    assertTrue("Decimal1 wasn't checked", lfdecimal1Checked);
    assertTrue("Decimal2 wasn't checked", lfdecimal2Checked);
    assertTrue("Decimal3 wasn't checked", lfdecimal3Checked);
    assertTrue("Decimal4 wasn't checked", lfdecimal4Checked);
    assertTrue("Decimal5 wasn't checked", lfdecimal6Checked);
    assertTrue("lfbool1 wasn't checked", lfbool1Checked);
    assertTrue("lfbool2 wasn't checked", lfbool2Checked);
    assertTrue("lfstr wasn't checked", lfstrChecked);
    assertTrue("lfstr1 wasn't checked", lfstr1Checked);
    assertTrue("lfbinary wasn't checked", lfbinaryChecked);
    assertTrue("lfempty wasn't checked", lfemptyChecked);
    // assertTrue("lfref1 wasn't checked", lfref1Checked);

    jReader.endObject();
  }
コード例 #19
0
 private void endArray() throws IOException {
   jsonReader.endArray();
   if (stackObj.peek().equals(topNestedArrayObj)) {
     topNestedArrayObj = null;
   }
 }
コード例 #20
0
ファイル: QuestAdapter.java プロジェクト: Bunsan/HQM
 @Override
 public QuestTask read(JsonReader in) throws IOException {
   in.beginObject();
   if (!in.nextName().equalsIgnoreCase(TYPE)) {
     throw new IOException("Tasks *MUST* start with the type");
   }
   String task = in.nextString();
   TaskType type = TaskType.valueOf(task);
   if (type == null) {
     throw new IOException("Invalid Task Type: " + task);
   }
   TASK = type.addTask(QUEST);
   while (in.hasNext()) {
     String name = in.nextName();
     if (name.equalsIgnoreCase(DESCRIPTION)) {
       TASK.description = in.nextString();
     } else if (name.equalsIgnoreCase(LONG_DESCRIPTION)) {
       TASK.setLongDescription(in.nextString());
     } else if (TASK instanceof QuestTaskItems && name.equalsIgnoreCase(ITEMS)) {
       List<QuestTaskItems.ItemRequirement> list = new ArrayList<>();
       in.beginArray();
       while (in.hasNext()) {
         QuestTaskItems.ItemRequirement entry = ITEM_REQUIREMENT_ADAPTER.read(in);
         if (entry != null) list.add(entry);
       }
       in.endArray();
       ((QuestTaskItems) TASK)
           .setItems(list.toArray(new QuestTaskItems.ItemRequirement[list.size()]));
     } else if (TASK instanceof QuestTaskDeath && name.equalsIgnoreCase(DEATHS)) {
       int death = in.nextInt();
       ((QuestTaskDeath) TASK).setDeaths(death);
     } else if (TASK instanceof QuestTaskLocation && name.equalsIgnoreCase(LOCATIONS)) {
       List<QuestTaskLocation.Location> list = new ArrayList<QuestTaskLocation.Location>();
       in.beginArray();
       while (in.hasNext()) {
         QuestTaskLocation.Location entry = LOCATION_ADAPTER.read(in);
         if (entry != null) list.add(entry);
       }
       in.endArray();
       ((QuestTaskLocation) TASK).locations =
           list.toArray(new QuestTaskLocation.Location[list.size()]);
     } else if (TASK instanceof QuestTaskMob && name.equalsIgnoreCase(MOBS)) {
       List<QuestTaskMob.Mob> list = new ArrayList<QuestTaskMob.Mob>();
       in.beginArray();
       while (in.hasNext()) {
         QuestTaskMob.Mob entry = MOB_ADAPTER.read(in);
         if (entry != null) list.add(entry);
       }
       in.endArray();
       ((QuestTaskMob) TASK).mobs = list.toArray(new QuestTaskMob.Mob[list.size()]);
     } else if (TASK instanceof QuestTaskReputation && name.equalsIgnoreCase(REPUTATION)) {
       List<QuestTaskReputation.ReputationSetting> list =
           new ArrayList<QuestTaskReputation.ReputationSetting>();
       in.beginArray();
       while (in.hasNext()) {
         list.add(REPUTATION_ADAPTER.read(in));
       }
       in.endArray();
       ReflectionHelper.setPrivateValue(
           QuestTaskReputation.class,
           (QuestTaskReputation) TASK,
           list.toArray(new QuestTaskReputation.ReputationSetting[list.size()]),
           "settings");
     } else if (name.equalsIgnoreCase(KILLS) && TASK instanceof QuestTaskReputationKill) {
       ((QuestTaskReputationKill) TASK).setKills(in.nextInt());
     }
   }
   in.endObject();
   type.addTaskData(QUEST);
   return null;
 }
コード例 #21
0
ファイル: QuestAdapter.java プロジェクト: Bunsan/HQM
 @Override
 public Quest read(JsonReader in) throws IOException {
   int ID_OFFSET = Quest.size();
   QUEST = new Quest(ID_OFFSET, "", "", 0, 0, false);
   List<Integer> requirement = new ArrayList<>(), options = new ArrayList<>();
   in.beginObject();
   while (in.hasNext()) {
     switch (in.nextName()) {
       case NAME:
         QUEST.setName(in.nextString());
         break;
       case DESCRIPTION:
         QUEST.setDescription(in.nextString());
         break;
       case X:
         ReflectionHelper.setPrivateValue(Quest.class, QUEST, in.nextInt(), X);
         break;
       case Y:
         ReflectionHelper.setPrivateValue(Quest.class, QUEST, in.nextInt(), Y);
         break;
       case TRIGGER_TASKS:
         QUEST.setTriggerTasks(in.nextInt());
         break;
       case PARENT_REQUIREMENT:
         QUEST.setParentRequirementCount(in.nextInt());
         break;
       case BIG_ICON:
         QUEST.setBigIcon(in.nextBoolean());
         break;
       case ICON:
         QUEST.setIcon(MinecraftAdapter.ITEM_STACK.read(in));
         break;
       case REQUIREMENTS:
         in.beginArray();
         while (in.hasNext()) {
           requirement.add(in.nextInt() + QUEST_ID);
         }
         in.endArray();
         break;
       case OPTIONS:
         in.beginArray();
         while (in.hasNext()) {
           options.add(in.nextInt() + QUEST_ID);
         }
         in.endArray();
         break;
       case REPEAT:
         QUEST.setRepeatInfo(REPEAT_INFO_ADAPTER.read(in));
         break;
       case TRIGGER:
         QUEST.setTriggerType(TriggerType.valueOf(in.nextString()));
         break;
       case TASKS:
         in.beginArray();
         while (in.hasNext()) {
           QuestTask task = TASK_ADAPTER.read(in);
           if (task != null) {
             QUEST.getTasks().add(task);
           }
         }
         in.endArray();
         break;
       case REWARDS:
         ReflectionHelper.setPrivateValue(
             Quest.class, QUEST, readItemStackArray(in), REWARDS);
         break;
       case REWARDS_CHOICE:
         ReflectionHelper.setPrivateValue(
             Quest.class, QUEST, readItemStackArray(in), REWARDS_CHOICE);
         break;
       case REWARDS_REPUTATION:
         in.beginArray();
         List<Quest.ReputationReward> reputationRewards = new ArrayList<>();
         while (in.hasNext()) {
           Quest.ReputationReward reward = REPUTATION_REWARD_ADAPTER.read(in);
           if (reward != null) reputationRewards.add(reward);
         }
         QUEST.setReputationRewards(reputationRewards);
         in.endArray();
         break;
     }
   }
   in.endObject();
   if (!QUEST.getName().isEmpty()) {
     requirementMapping.put(QUEST, requirement);
     optionMapping.put(QUEST, options);
     return QUEST;
   }
   QuestLine.getActiveQuestLine().quests.remove(QUEST.getId());
   return null;
 }