androidjsonandroid-json

Parse Json and Print in ListView


I have a JSON Link here JSON LINK

How to parse this to get only One Tag of many its name but that tag must contains every id of its node.. For example here One tag is Social Emotional that is more than 10 times having its different-2 is. but i want to select only its first tag that should contains its all id and description of its matching name. please help me . I am unable to parse it.. Screen Shot of JSON is here SCREENSHOT IMAGE What I did is here..

  protected void onPostExecute(JSONObject json) {
     pDialog.dismiss();
     try {
            // Getting JSON Array from URL
            android = json.getJSONArray(TAG_OS);
            for(int i = 0; i < android.length(); i++){
            JSONObject c = android.getJSONObject(i);
            c = c.getJSONObject("LearningStandards");



            // Storing  JSON item in a Variable
            String ver = c.getString(TAG_VER);
            String name = c.getString(TAG_NAME);
            //String api = c.getString(TAG_API);




            // Adding value HashMap key => value


            HashMap<String, String> map = new HashMap<String, String>();

            map.put(TAG_VER, ver);
            map.put(TAG_NAME, name);
            //map.put(TAG_API, api);

            oslist.add(map);

Solution

  • this is the code for you. you can fetch the value like this parsing steps.

    String strJSONData = networkManager.doPost("http://54.152.108.131/iphone111/getLearningStandards");
    
                        JSONArray objJson = new JSONArray(strJSONData);
    
    
    
                             System.out.println("AppUserLogin:"+objJson);
                            // Parsing json
    
    
                            if(arrJson.length()>0)
                            {
                            for (int i = 0; i < objJson.length(); i++) {
                                try {
                                    JSONObject objprod = arrJson.getJSONObject(i);
    
                                    HashMap<String, String> MaplistTemp = new HashMap<String, String>();
                                    MaplistTemp.put("replyCode",
                                            objprod.getString("replyCode"));
    
                                    MaplistTemp.put("replyCode",
                                            objprod.getString("replyCode"));
    
                                    JSONArray objproduct_var = new JSONArray(objprod.getString("LearningStandards"));
    
                                    if ((objproduct_var.length()) > 0) {
                                        for (int k = 0; k < objproduct_var.length(); k++) {
                                            JSONObject objprodvar = objproduct_var
                                                    .getJSONObject(k);
    
    
    
                                                MaplistTemp
                                                        .put("1",
                                                                objprodvar
                                                                        .getString("1"));
                                                MaplistTemp
                                                        .put("2",
                                                                objprodvar
                                                                        .getString("2"));
                                                MaplistTemp
                                                        .put("3",
                                                                objprodvar
                                                                        .getString("3"));
                                                MaplistTemp
                                                .put("4",
                                                        objprodvar
                                                                .getString("4"));
    
                                        }
                                    }
                                    // sub_categorys_details.add(sub_cat_det);
    
                            medpostList.add(MaplistTemp);// adding to final hashmap
                                } catch (JSONException e) {
                                    e.printStackTrace();
                                }
    
                            }
                        }
    

    your url have another array so do it again in "k" for loop and create another for loop j and get the value. Note dopost method return type is String. if you have json object then use it accordingly.