w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
jsonobject cannot be converted to jsonarray nested jsonarray android
{ // json object
    "dialog_details": [ // json array
            "msg": "success", 
            "dialogdetails": { // json object
              "dialog_id": "139",            

dialogdetails is not a JSONArray its a JSONObject

Change to JSONObject

dialogs = d.getJSONArray("dialogdetails");


JSONObject dialogs = d.getJSONObject("dialogdetails");

[ represents json array node

{ represetns json object node

    JSONObject jb = new JSONObject("myjsonstring");
    JSONArray jr = (JSONArray)jb.getJSONArray("dialog_details"):
    for(int i=0;i<jr.length();i++)
       JSONObject d = (JSONObject) jr.getJSONObject(i);
       String msg = d.getString(TAG_MSG);
       JSONObject dialogs = d.getJSONObject("dialogdetails");
       String dialog_id= dialogs.getString("dialog_id");   

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.