-1

i am having a issue of parsing JSON data i followed this link..

over there it has parsing data images description..

and i also refereed this in stack over flow a guy who is having same issue but no correct answer.. How to Parse JSONarray inside JSONarray in android? and How to display Image from URL?

we can say just extention of the above questions..

its not a duplicate that guy is also same problem no answer..

i have a data like below

{
"request": "ok",
"query": {
    "result": [
        {
            "site": [
                {
                    "latest": [
                        {
                            "id": "2eaQy8Ow",
                            "data": "1/1/2014"
                        }
                    ]
                }
            ],
            "flag": [
                "http://www.simplydecoded.com/wp-content/uploads/2013/02/Telangana2.jpg"
            ]
        }
    ]
   }
  }

i am using below code for parsing

JSONArray json_query_flag = c.getJSONArray("flag");


JSONArray json_query_site=c.getJSONArray("site");
System.out.println("looping json_query_site");
for (int j = 0; j < c.length(); j++) {
System.out.println("looping json_query_site[" + j +"]" + "json_query_site.length() -->" + json_query_site.length());

if (j <json_query_site.length()) {

HashMap<String, String> map1 = new HashMap<String, String>();
JSONObject sd = json_query_site.getJSONObject(j);

// get latestoffers
JSONArray json_latest = sd.getJSONArray("latest");
System.out.println(json_latest.toString());

for (int k = 0; k < json_latest.length(); k++) {

HashMap<String, String> map2 = new HashMap<String, String>();
JSONObject e = json_latest.getJSONObject(k);

My problem is that i am not getting the latest and flag.. may be parsing problem..

2
  • Sir that is in c# i am in java android .. and my code is designed from this url androidbegin.com/tutorial/… Commented Dec 21, 2013 at 8:31
  • Sorry this is answer stackoverflow.com/questions/20635220/… is no way related to question.. Commented Dec 23, 2013 at 9:24

2 Answers 2

1

Hellow man thanks for understanding the problem please follow this post for the till your site and latest..

it solved I am getting text.. but problem with images I think you have flag.. for that you need to change your Listviewadapter.java file. so that images will appear

change this like

String strflag = resultp.get(Mainactivity.IMAGES);
    if(strflag != null)
        imageLoader.DisplayImage(strflag, flag);
    else
        imageLoader.DisplayImage("http://www.butterentals.com/graphics/no_image.jpg", flag);

so that I will be done.

Sign up to request clarification or add additional context in comments.

Comments

1

TRy this..

JSONObject JObj = new JSONObject(response);
JSONObject query = JObj.getJSONObject("query");
JSONArray result = query.getJSONArray("result");
for (int i = 0; i < result.length(); i++) {
        JSONObject jobj = result.getJSONObject(i);
        JSONArray site = jobj.getJSONArray("site");
            for (int j = 0; j < site.length(); j++) {
                JSONObject sitobj = site.getJSONObject(j);
                JSONArray latest = sitobj.getJSONArray("latest");
                    for (int k = 0; k < latest.length(); k++) {
                         JSONObject lateobj = latest.getJSONObject(k);
                         System.out.println("id : "+lateobj.getString("id"));
                    }
            }
        JSONArray flag = jobj.getJSONArray("flag");
        for (int l = 0; l < flag.length(); l++) {
            System.out.println("urls : "+flag.getString(l));
        }
}

6 Comments

@user3124880 can you post your full parsing code that missing C JSONObject
@user3124880 yes i know that. for your json response my ans is correct. May i know what you want.
@user3124880 sorry friend i'm in office i cannot open my mail here. you can post your parsing code i can help you.
@user3124880 see my ans take that code and use it. check that in logcat that urls will print.
@user3124880 in hashmap1 which data you need to store.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.