parse json news feed array android
- by user1827260
I have an json feed from bbc in this format
{
"name": "ticker",
"entries": [
{
"headline": "text",
"prompt": "LATEST",
"isBreaking": "false",
"mediaType": "Standard",
"url": ""
},
{
"headline": "text",
"prompt": "LATEST",
"isBreaking": "false",
"mediaType": "Standard",
"url": ""
}, etc...........
My code is as follows:
ArrayList mylist = new ArrayList();
JSONObject json = JSONfunctions.getJSONfromURL("http:/......");
try{
JSONArray item = json.getJSONArray("entries");
for (int i = 0; i<item.length(); i++) {
HashMap<String, String> map = new HashMap<String, String>();
JSONObject e = item.getJSONObject(i);
JSONObject title = e.JSONObject("headline");
map.put("title", "Title:" + e.getString("headline");
}
It gives me the error "java.lang.String cannot be converted to JSONObject"
I also tried leaving out JSONObject title = e.JSONObject("headline"); and it gives me a path error (note