protected <V>V parseJson(InputStream stream,Type type,Type listType) throws IOException {
  BufferedReader reader=new BufferedReader(new InputStreamReader(stream,CHARSET_UTF8),bufferSize);
  if (listType == null)   try {
    return gson.fromJson(reader,type);
  }
 catch (  JsonParseException jpe) {
    L.e(jpe);
    IOException ioe=new IOException("Parse exception converting JSON to object");
    ioe.initCause(jpe);
    throw ioe;
  }
 finally {
    try {
      reader.close();
    }
 catch (    IOException ignored) {
    }
  }
 else {
    JsonReader jsonReader=new JsonReader(reader);
    try {
      if (jsonReader.peek() == BEGIN_ARRAY)       return gson.fromJson(jsonReader,listType);
 else       return gson.fromJson(jsonReader,type);
    }
 catch (    JsonParseException jpe) {
      L.e(jpe);
      IOException ioe=new IOException("Parse exception converting JSON to object");
      ioe.initCause(jpe);
      throw ioe;
    }
 finally {
      try {
        jsonReader.close();
      }
 catch (      IOException ignored) {
      }
    }
  }
}

protected < V > V parseJson ( InputStream stream , Type type , Type listType ) throws IOException { BufferedReader reader = new BufferedReader ( new InputStreamReader ( stream , CHARSET_UTF8 ) , bufferSize ) ; if ( listType == null ) try { return gson . fromJson ( reader , type ) ; } catch ( JsonParseException jpe ) { L . e ( jpe ) ; IOException ioe = new IOException ( "Parse exception converting JSON to object" ) ; ioe . initCause ( jpe ) ; throw ioe ; } finally { try { reader . close ( ) ; } catch ( IOException ignored ) { } } else { JsonReader jsonReader = new JsonReader ( reader ) ; try { if ( jsonReader . peek ( ) == BEGIN_ARRAY ) return gson . fromJson ( jsonReader , listType ) ; else return gson . fromJson ( jsonReader , type ) ; } catch ( JsonParseException jpe ) { L . e ( jpe ) ; IOException ioe = new IOException ( "Parse exception converting JSON to object" ) ; ioe . initCause ( jpe ) ; throw ioe ; } finally { try { jsonReader . close ( ) ; } catch ( IOException ignored ) { } } } }
parse json to specified type
