-5

This is my JSON Array and Object.

{
"table1": [
    {
        "item_id": "1",
        "items": [
            "Veg Snacker",
            "Chicken Snacker",
            "Snack Box *1pc. Chicken & Fries",
            "Chicken Rizo",
            "Veg Stripes",
            "Popcorn Chicken"
        ]
    }
],
"success": 1
}

So, I want to display this items String Value into android ListView. I tried allot but I can't get it. so please if anyone know how to convert json string value into an ArrayList.

I want Output like:

Veg Snacker
Chicken Snacker
Snack Box..... ect,
Ram kiran Pachigolla
  • 20,897
  • 15
  • 57
  • 78

1 Answers1

0

This should get you started:

 String jsonString = "PUT JSON STRING HERE";
    JsonObject object = new JsonObject(jsonString);
    JsonArray tables = object.getJsonArray("table1");
    for(JsonObject value: tables){

        JsonArray items = value.getJsonArray("items");
        for(JsonObject item: items){
            Log.i("TAG",item.toString());
        }

    }

Keep in mind this solution does not have any error handling. I also have not tested this, I just quickly wrote it.

StackOverflower
  • 410
  • 3
  • 9