Created
June 16, 2012 07:31
-
-
Save ericsaboia/2940386 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 static List<Category> getList() { | |
Gson gson = new Gson(); | |
String json_string = API.getJSON("http://u8r.herokuapp.com/categories.json"); | |
return Arrays.asList(gson.fromJson(json_string, Category[].class)); | |
} | |
public static List<Category> getSubList(Integer category_id) { | |
Gson gson = new Gson(); | |
String json_string = API.getJSON("http://u8r.herokuapp.com/categories.json?category_id = "+category_id.toString()); | |
List<Category> sub_categories = Arrays.asList(gson.fromJson(json_string, Category[].class)); | |
for (Category sub_category : sub_categories) { | |
String product_json_string = API.getJSON("http://u8r.herokuapp.com/products.json?category_id = "+sub_category.getId().toString()); | |
List<Product> products = Arrays.asList(gson.fromJson(product_json_string, Product[].class)); | |
sub_category.setProducts(products); | |
} | |
return sub_categories; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment