Skip to content
Advertisement

How to parse array inside json object in android java?

how to display array data in json object if the json data is like below. I want to display array data of Ingredient and step. This is the full API Address that I want to fetch the data https://masak-apa-tomorisakura.vercel.app/api/recipe/resep-nasi-bakar-ayam

enter image description here

I’ve tried several ways but I can’t find how to implement it properly.

this is my json model.

JavaScript

This is the code I use to display the data

JavaScript

This is the error that android studio shows enter image description here

enter image description here

Thanks, I hope someone gives an example project that displays array data in a json object like my problem above.

UPDATE

Thanks Gralls, I can display the array data by creating a new string and implementing

JavaScript

it into the previously created string. Then how to make the data ingredient can be in the form of a list? enter image description here

Advertisement

Answer

I don’t have an example project but ingredients is array of strings. So instead of having

JavaScript

you should parse array into some sort of the list

JavaScript

I hope that this will help 🙂

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement