-3

Please help me to sort out this issue.

See this example below, I wanted to get this data in listview. How can we do this?

{"Afpak":{"id":1,"race":"hybrid","flavors":["Earthy","Chemical","Pine"],"effects":{"positive":["Relaxed","Hungry","Happy","Sleepy"],"negative":["Dizzy"],"medical":["Depression","Insomnia","Pain","Stress","Lack of Appetite"]}},"African":{"id":2,"race":"sativa","flavors":["Spicy/Herbal","Pungent","Earthy"],"effects":{"positive":["Euphoric","Happy","Creative","Energetic","Talkative"],"negative":["Dry Mouth"],"medical":["Depression","Pain","Stress","Lack of Appetite","Nausea","Headache"]}}}

enter image description here

P A Gosai
  • 553
  • 5
  • 22

3 Answers3

1

You can do the parsing in an easy way,First you have to Install AwesomePojoGenerator. Generate model classes from the above json using AwesomePojoGenerator and then use google's GSON library to do parsing.

OutputClass outputClass=new Gson().fromJson(jsonString,OutputClass.class)
Jinesh Francis
  • 3,377
  • 3
  • 22
  • 37
0

This above is JsonObject but you need here a JsonArray for parsing it in listview.

[{"id":1,"race":"hybrid","flavors":["Earthy","Chemical","Pine"],"effects":{"positive":["Relaxed","Hungry","Happy","Sleepy"],"negative":["Dizzy"],"medical":["Depression","Insomnia","Pain","Stress","Lack of Appetite"]}},{"id":2,"race":"sativa","flavors":["Spicy/Herbal","Pungent","Earthy"],"effects":{"positive":["Euphoric","Happy","Creative","Energetic","Talkative"],"negative":["Dry Mouth"],"medical":["Depression","Pain","Stress","Lack of Appetite","Nausea","Headache"]}}]

Please fix your json and parse it as Jsonarray in api call

Govind Prajapati
  • 208
  • 3
  • 10
0

Do you have any template of list view to show because you can not show these value on normal iteration in your list view because iterate over json array and json object is different to get data.

mohit
  • 88
  • 9