Exemple #1
0
 public static <D> D parse(InputStream is, Class<D> parseClass) throws ParseException {
   try {
     return LoganSquare.parse(is, parseClass);
   } catch (Exception e) {
     throw new ParseException(e);
   }
 }
 public static ParcelableCardEntity fromJSONString(final String json) {
   if (TextUtils.isEmpty(json)) return null;
   try {
     return LoganSquare.parse(json, ParcelableCardEntity.class);
   } catch (final IOException e) {
     return null;
   }
 }
 private Object getObject(Cursor cursor, int columnIndex, ParameterizedType fieldType)
     throws IOException {
   final Type rawType = fieldType.getRawType();
   if (!(rawType instanceof Class)) throw new UnsupportedOperationException();
   final Class rawCls = (Class) rawType;
   final String string = cursor.getString(columnIndex);
   if (TextUtils.isEmpty(string)) return null;
   if (List.class.isAssignableFrom(rawCls)) {
     // Parse list
     return LoganSquare.parseList(string, (Class) fieldType.getActualTypeArguments()[0]);
   } else if (Map.class.isAssignableFrom(rawCls)) {
     return LoganSquare.parseMap(string, (Class) fieldType.getActualTypeArguments()[1]);
   } else if (rawCls.isArray()) {
     final Class componentType = rawCls.getComponentType();
     List<?> list = LoganSquare.parseList(string, componentType);
     return list.toArray((Object[]) Array.newInstance(componentType, list.size()));
   }
   return LoganSquare.parse(string, rawCls);
 }
 private MoviesList generateMoviesList() throws IOException {
   InputStream inputStream = TestResourceLoader.load(this, "tmdb_popular_1.json");
   return MoviesList.create(LoganSquare.parse(inputStream, MoviesListResponse.class));
 }