Created
October 3, 2017 18:13
-
-
Save PierceZ/31f9876e50ca9737373c9f59583872be to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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