parse json news feed array android
Posted
by
user1827260
on Stack Overflow
See other posts from Stack Overflow
or by user1827260
Published on 2012-11-15T16:57:47Z
Indexed on
2012/11/15
16:59 UTC
Read the original article
Hit count: 131
android
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
© Stack Overflow or respective owner