Code example for JsonReader

0
   * @throws JsonSyntaxException if json is not a valid representation for an object of type 
   * @since 1.2 
   */ 
  @SuppressWarnings("unchecked") 
  public <T> T fromJson(Reader json, Type typeOfT) throws JsonIOException, JsonSyntaxException {
    JsonReader jsonReader = new JsonReader(json);
    T object = (T) fromJson(jsonReader, typeOfT);
    assertFullConsumption(object, jsonReader);
    return object;
  } 
 
  private static void assertFullConsumption(Object obj, JsonReader reader) {
    try { 
      if (obj != null && reader.peek() != JsonToken.END_DOCUMENT) {
        throw new JsonIOException("JSON document was not fully consumed.");
      } 
    } catch (MalformedJsonException e) {
      throw new JsonSyntaxException(e);
    } catch (IOException e) {
      throw new JsonIOException(e);
Contextual code suggestions in your IDE  Get Codota for Java