-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,
0

1 Answer 1

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.

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.