public <T> T nextObject(boolean optional, ObjectReader<T> objectReader) throws IOException { checkNextValue(optional); if (jsonReader.peek() == JsonReader.Token.NULL) { jsonReader.skipValue(); return null; } else { jsonReader.beginObject(); T result = objectReader.read(this); jsonReader.endObject(); return result; } }
public Integer nextInt(boolean optional) throws IOException { checkNextValue(optional); if (jsonReader.peek() == JsonReader.Token.NULL) { jsonReader.skipValue(); return null; } else { return jsonReader.nextInt(); } }
public Boolean nextBoolean(boolean optional) throws IOException { checkNextValue(optional); if (jsonReader.peek() == JsonReader.Token.NULL) { jsonReader.skipValue(); return null; } else { return jsonReader.nextBoolean(); } }
@Override public Object read(ResponseJsonStreamReader reader) throws IOException { if (streamReader.isNextList()) { return readList(reader); } else if (streamReader.isNextObject()) { return readObject(reader); } else { return reader.nextScalar(true); } } });
public Double nextDouble(boolean optional) throws IOException { checkNextValue(optional); if (jsonReader.peek() == JsonReader.Token.NULL) { jsonReader.skipValue(); return null; } else { return jsonReader.nextDouble(); } }
public Long nextLong(boolean optional) throws IOException { checkNextValue(optional); if (jsonReader.peek() == JsonReader.Token.NULL) { jsonReader.skipValue(); return null; } else { return jsonReader.nextLong(); } }
public String nextString(boolean optional) throws IOException { checkNextValue(optional); if (jsonReader.peek() == JsonReader.Token.NULL) { jsonReader.skipValue(); return null; } else { return jsonReader.nextString(); } }
private Map<String, Object> fromBufferSource(BufferedSource bufferedFieldSource) throws IOException { final CacheJsonStreamReader cacheJsonStreamReader = cacheJsonStreamReader(bufferedSourceJsonReader(bufferedFieldSource)); return cacheJsonStreamReader.toMap(); }
private void writeDeferredName() throws IOException { if (deferredName != null) { beforeName(); string(sink, deferredName); deferredName = null; } }
@Override public boolean hasNext() throws IOException { int p = peeked; if (p == PEEKED_NONE) { p = doPeek(); } return p != PEEKED_END_OBJECT && p != PEEKED_END_ARRAY; }
private void checkLenient() throws IOException { if (!lenient) { throw syntaxError("Use JsonReader.setLenient(true) to accept malformed JSON"); } }
/** * Returns a <a href="http://goessner.net/articles/JsonPath/">JsonPath</a> to * the current location in the JSON value. */ public final String getPath() { return JsonScope.getPath(stackSize, scopes, pathNames, pathIndices); } }
private List<Error> readResponseErrors(ResponseJsonStreamReader reader) throws IOException { return reader.nextList(true, new ResponseJsonStreamReader.ListReader<Error>() { @Override public Error read(ResponseJsonStreamReader reader) throws IOException { return reader.nextObject(true, new ResponseJsonStreamReader.ObjectReader<Error>() { @Override public Error read(ResponseJsonStreamReader reader) throws IOException { return readError(reader.toMap()); } }); } }); }