public static JSONObject serialize(RecentSearch search) throws JSONException { JSONObject recent = new JSONObject(); recent.put(SEARCH_COUNT, search.getCount()); Search type = search.getSearch(); JSONObject si = new JSONObject(); JSONObject text = new JSONObject(); LocationSearch p = (LocationSearch) type; text.put(SEARCH_QUERY, p.getQuery()); text.put(SEARCH_LABEL, p.getLabel()); si.put(GEO_SEARCH, text); recent.put(SEARCH_TYPES, si); return recent; }