Skip to content

Instantly share code, notes, and snippets.

@billmote
Last active August 29, 2015 14:16
Show Gist options
  • Save billmote/343b68b56020ee51c345 to your computer and use it in GitHub Desktop.
Save billmote/343b68b56020ee51c345 to your computer and use it in GitHub Desktop.
An alternative to the custom TypeAdapter to handle Rotten Tomatoes returning different JSON primitives for Movie runtime
@DebugLog
public class Movie {
@Expose
public Object runtime;
// ...
public Integer getMovieRuntime() {
if (runtime instanceof String && !TextUtils.isEmpty((String) runtime)) {
return Integer.valueOf((String) runtime);
} else if (runtime instanceof Integer) {
return (Integer) runtime;
} else return 0;
}
public void setMovieRuntime(Object runtime) {
this.runtime = runtime;
}
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment