JSONArray items = extractItemsFromStream(is);
int numberOfResults = items.length() <= MAX_NUMBER_OF_ITEMS_TO_RETURN ? items.length() : MAX_NUMBER_OF_ITEMS_TO_RETURN;
for (int i = 0; i<numberOfResults; i++) {
JSONObject result = items.getJSONObject(i);
FlickrItem flickrItem = new FlickrItem();
flickrItem.setTitle(result.getString("title"));
flickrItem.setAuthorId(result.getString("author_id"));
flickrItem.setFlickrUrl(result.getString("link"));
flickrItem.setImgUrl(result.getJSONObject("media").getString("m"));
flickrItems.add(flickrItem);
}
return flickrItems;
}