Source:
public SearchResults processResult(final ApiResult result) throws Throwable { JSONObject data; try { data = result.asObject(); } catch (ApiException e) { if (e.getCause() instanceof JSONException) { return new SearchResults(); } else { throw new RuntimeException(e); } } FTContinueOffset nextContinueOffset = null; final JSONObject continueData = data.optJSONObject("continue"); if (continueData != null) { String continueString = continueData.optString("continue", null); Integer gsroffset = continueData.optInt("gsroffset"); nextContinueOffset = new FTContinueOffset(continueString, gsroffset); } JSONObject queryResult = data.optJSONObject("query"); if (queryResult == null) { return new SearchResults(); } JSONObject pages = queryResult.optJSONObject("pages"); if (pages == null) { return new SearchResults(); } JSONObject[] pageArray = new JSONObject[pages.length()]; int pageIndex = 0; Iterator<String> pageIter = pages.keys(); while (pageIter.hasNext()) { pageArray[pageIndex++] = (JSONObject)pages.get(pageIter.next()); } Arrays.sort(pageArray, new Comparator<JSONObject>() { @Override public int compare(JSONObject lhs, JSONObject rhs) { int ret = 0; try { ret = ((Integer) lhs.getInt("index")).compareTo(rhs.getInt("index")); } catch (JSONException e) { } return ret; } }); ArrayList<PageTitle> pageTitles = new ArrayList<>(); for (JSONObject item : pageArray) { String thumbUrl = null; if (item.has("thumbnail")) { thumbUrl = item.getJSONObject("thumbnail").optString("source", null); } String description = null; if (item.has("terms")) { JSONArray arr = item.getJSONObject("terms").optJSONArray("description"); if (arr != null && arr.length() > 0) { description = Utils.capitalizeFirstChar(arr.getString(0)); } } JSONObject pageprops = null; if (item.has("pageprops")) { pageprops = item.getJSONObject("pageprops"); } pageTitles.add(new PageTitle(item.getString("title"), site, thumbUrl, description, pageprops)); } return new SearchResults(pageTitles, nextContinueOffset, null); }

Target:
public SearchResults processResult(final ApiResult result) throws Throwable { JSONObject data; try { data = result.asObject(); } catch (ApiException e) { if (e.getCause() instanceof JSONException) { return new SearchResults(); } else { throw new RuntimeException(e); } } FTContinueOffset nextContinueOffset = null; final JSONObject continueData = data.optJSONObject("continue"); if (continueData != null) { String continueString = continueData.optString("continue", null); Integer gsroffset = continueData.optInt("gsroffset"); nextContinueOffset = new FTContinueOffset(continueString, gsroffset); } JSONObject queryResult = data.optJSONObject("query"); if (queryResult == null) { return new SearchResults(); } JSONObject pages = queryResult.optJSONObject("pages"); if (pages == null) { return new SearchResults(); } JSONObject[] pageArray = new JSONObject[pages.length()]; int pageIndex = 0; Iterator<String> pageIter = pages.keys(); while (pageIter.hasNext()) { pageArray[pageIndex++] = (JSONObject)pages.get(pageIter.next()); } Arrays.sort(pageArray, new Comparator<JSONObject>() { @Override public int compare(JSONObject lhs, JSONObject rhs) { int ret = 0; try { ret = ((Integer) lhs.getInt("index")).compareTo(rhs.getInt("index")); } catch (JSONException e) { } return ret; } }); ArrayList<PageTitle> pageTitles = new ArrayList<>(); for (JSONObject item : pageArray) { String thumbUrl = null; if (item.has("thumbnail")) { thumbUrl = item.getJSONObject("thumbnail").optString("source", null); } String description = null; if (item.has("terms")) { JSONArray arr = item.getJSONObject("terms").optJSONArray("description"); if (arr != null && arr.length() > 0) { description = Utils.capitalizeFirstChar(arr.getString(0)); } } PageProperties properties = null; if (item.has("pageprops")) { properties = new PageProperties(item.getJSONObject("pageprops")); } pageTitles.add(new PageTitle(item.getString("title"), site, thumbUrl, description, properties)); } return new SearchResults(pageTitles, nextContinueOffset, null); }