[Solved] how to parsing Json Array in android? [closed]


JSONArray json = jParser.getJSONFromUrl(URL);

try {
    JSONObject c = json.getJSONObject(0);
JSONArray json1  = c.getJSONArray("products");                      
status = c.getString("num_page"); 

for(int i=0;i<json1.length();i++){

    JSONObject c1 = json1.getJSONObject(i);
    String des = c1.getString("description");
    String pid = c1.getString("product_id");
    String name = c1.getString("name");
    String pc = c1.getString("product_code");
    String images = c1.getString("images");
    String price = c1.getString("price");
    String weight = c1.getString("weight");

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

    // adding each child node to HashMap key => value
    map.put("description", des);
    map.put("product_id", pid);
    map.put("name", name);
    map.put("product_code",pc);
    map.put("images", images);
    map.put("price", price);
    map.put("weight", weight);                         

    fetch.add(map);
}

copy paste the code and use it, fetch is your arraylist of hashmap and if any problem persist then let me know.

1

solved how to parsing Json Array in android? [closed]