Esempio n. 1
0
 public <T> T fromJson(JsonReader jsonReader, Type type)
     throws JsonIOException, JsonSyntaxException {
   boolean z = true;
   boolean isLenient = jsonReader.isLenient();
   jsonReader.setLenient(true);
   try {
     jsonReader.peek();
     z = DEFAULT_JSON_NON_EXECUTABLE;
     T read = getAdapter(TypeToken.get(type)).read(jsonReader);
     jsonReader.setLenient(isLenient);
     return read;
   } catch (Throwable e) {
     if (z) {
       jsonReader.setLenient(isLenient);
       return null;
     }
     throw new JsonSyntaxException(e);
   } catch (Throwable e2) {
     throw new JsonSyntaxException(e2);
   } catch (Throwable e22) {
     throw new JsonSyntaxException(e22);
   } catch (Throwable th) {
     jsonReader.setLenient(isLenient);
   }
 }
Esempio n. 2
0
 /**
  * Reads the next JSON value from {@code reader} and convert it to an object of type {@code
  * typeOfT}. Since Type is not parameterized by T, this method is type unsafe and should be used
  * carefully
  *
  * @throws JsonIOException if there was a problem writing to the Reader
  * @throws JsonSyntaxException if json is not a valid representation for an object of type
  */
 @SuppressWarnings("unchecked")
 public <T> T fromJson(JsonReader reader, Type typeOfT)
     throws JsonIOException, JsonSyntaxException {
   boolean isEmpty = true;
   boolean oldLenient = reader.isLenient();
   reader.setLenient(true);
   try {
     reader.peek();
     isEmpty = false;
     TypeToken<T> typeToken = (TypeToken<T>) TypeToken.get(typeOfT);
     TypeAdapter<T> typeAdapter = getAdapter(typeToken);
     T object = typeAdapter.read(reader);
     return object;
   } catch (EOFException e) {
     /*
      * For compatibility with JSON 1.5 and earlier, we return null for empty
      * documents instead of throwing.
      */
     if (isEmpty) {
       return null;
     }
     throw new JsonSyntaxException(e);
   } catch (IllegalStateException e) {
     throw new JsonSyntaxException(e);
   } catch (IOException e) {
     // TODO(inder): Figure out whether it is indeed right to rethrow this as JsonSyntaxException
     throw new JsonSyntaxException(e);
   } finally {
     reader.setLenient(oldLenient);
   }
 }
Esempio n. 3
0
 public JsonElement parse(JsonReader jsonreader)
     throws JsonIOException, JsonSyntaxException
 {
     boolean flag;
     flag = jsonreader.isLenient();
     jsonreader.setLenient(true);
     JsonElement jsonelement = Streams.parse(jsonreader);
     jsonreader.setLenient(flag);
     return jsonelement;
     Object obj;
     obj;
     throw new JsonParseException((new StringBuilder()).append("Failed parsing JSON source: ").append(jsonreader).append(" to Json").toString(), ((Throwable) (obj)));
     obj;
     jsonreader.setLenient(flag);
     throw obj;
     obj;
     throw new JsonParseException((new StringBuilder()).append("Failed parsing JSON source: ").append(jsonreader).append(" to Json").toString(), ((Throwable) (obj)));
 }