Skip to content

Instantly share code, notes, and snippets.

@PierceZ
Created October 3, 2017 18:13
Show Gist options
  • Save PierceZ/31f9876e50ca9737373c9f59583872be to your computer and use it in GitHub Desktop.
Save PierceZ/31f9876e50ca9737373c9f59583872be to your computer and use it in GitHub Desktop.
public class ZooParser {
private String mResponse;
private Zoo mZoo;
private List<Zoo> mZooList;
private List<Animal> mAnimalList;
private Gson mGson;
public ZooParser(String response) {
mResponse = response;
mGson = new Gson();
}
public void parseZooList() {
if (mResponse != null) {
Zoo[] zoos = mGson.fromJson(mResponse, Zoo[].class);
mZooList = Arrays.asList(zoos);
}
}
public void parseZoo() {
if (mResponse != null) {
mZoo = mGson.fromJson(mResponse, Zoo.class);
}
}
public Zoo getZoo() {
return mZoo;
}
public List<Zoo> getZooList() {
return mZooList;
}
public List<Animal> getAnimalList() {
return mAnimalList;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment