public static ArrayList<OpportunityCategory> parseCategories(String jsonResponse) throws PBException { ArrayList<OpportunityCategory> cats = null; String TAG = className + ".parseCategories"; PBLogger.entry(TAG); try { JSONArray jsonArray = new JSONArray(jsonResponse); cats = new ArrayList<OpportunityCategory>(jsonArray.length()); jsonArray = new JSONArray(jsonResponse); for (int i = 0; i < jsonArray.length(); i++) { JSONObject jsonObj = jsonArray.getJSONObject(i); OpportunityCategory cat = new OpportunityCategory(); cat.setId(jsonObj.getInt(Constants.CATEGORY_ID)); cat.setName(jsonObj.getString(Constants.CATEGORY_NAME)); cats.add(cat); } } catch (JSONException e) { throw new PBException(resources.getString(R.string.errorTryingToParseCategories), e); } PBLogger.d(TAG, "returning cats = " + cats); PBLogger.exit(TAG); return cats; }