# How to iterate through JSON results and display

**URL:** https://community.thunkable.com/t/how-to-iterate-through-json-results-and-display/1380052
**Category:** Questions about Thunkable X
**Tags:** webapi, json
**Created:** [July 5, 2021, 1:42pm UTC](https://community.thunkable.com/t/how-to-iterate-through-json-results-and-display/1380052 "2021-07-05T13:42:18Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![mpokrzywinskimc6ua](https://avatars.discourse-cdn.com/v4/letter/m/a587f6/32.png) [@mpokrzywinskimc6ua](https://community.thunkable.com/u/mpokrzywinskimc6ua)
#### Post date: [July 5, 2021, 1:42pm UTC](https://community.thunkable.com/t/how-to-iterate-through-json-results-and-display/1380052/1 "2021-07-05T13:42:18Z")

</div>

I am having difficulty coding for a variable number of results to be returned and displayed on a screen. The code works to return item 1 (without the for each item loop), but when I add that block and the display of the app\_variable\_ListofNames, I get nothing or a ‘,’ when there are multiple results. I tried swapping out to a list viewer control, but that didn’t work for me either.

Here is the code:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/5/f/5f9bbbcddf172ec1d2c71a7238cdc581f3f6b20a.png)

and here is an example of the JSON output it reads:

{  
“normalizedInput”: {  
“line1”: “”,  
“city”: “Eden Prairie”,  
“state”: “MN”,  
“zip”: “55347”  
},  
“kind”: “civicinfo#representativeInfoResponse”,  
“divisions”: {  
“ocd-division/country:us/state:mn”: {  
“name”: “Minnesota”,  
“officeIndices”: [  
0  
]  
}  
},  
“offices”: [  
{  
“name”: “U.S. Senator”,  
“divisionId”: “ocd-division/country:us/state:mn”,  
“levels”: [  
“country”  
],  
“roles”: [  
“legislatorUpperBody”  
],  
“officialIndices”: [  
0,  
1  
]  
}  
],  
“officials”: [  
{  
“name”: “Amy Klobuchar”,  
“address”: [  
{  
“line1”: “425 Dirksen Senate Office Building”,  
“city”: “Washington”,  
“state”: “DC”,  
“zip”: “20510”  
}  
],  
“party”: “Democratic Party”,  
“phones”: [  
“(202) 224-3244”  
],  
“urls”: [  
“[https://www.klobuchar.senate.gov/](https://www.klobuchar.senate.gov/)”  
],  
“photoUrl”: “[http://bioguide.congress.gov/bioguide/photo/K/K000367.jpg](http://bioguide.congress.gov/bioguide/photo/K/K000367.jpg)”,  
“channels”: [  
{  
“type”: “Facebook”,  
“id”: “amyklobuchar”  
},  
{  
“type”: “Twitter”,  
“id”: “amyklobuchar”  
}  
]  
},  
{  
“name”: “Tina Smith”,  
“address”: [  
{  
“line1”: “720 Hart Senate Office Building”,  
“city”: “Washington”,  
“state”: “DC”,  
“zip”: “20510”  
}  
],  
“party”: “Democratic Party”,  
“phones”: [  
“(202) 224-5641”  
],  
“urls”: [  
“[https://www.smith.senate.gov/](https://www.smith.senate.gov/)”  
],  
“photoUrl”: “[https://mn.gov/governor/assets/press\_smith-2015\_tcm1055-154819.jpg](https://mn.gov/governor/assets/press_smith-2015_tcm1055-154819.jpg)”,  
“channels”: [  
{  
“type”: “Facebook”,  
“id”: “USSenTinaSmith”  
},  
{  
“type”: “Twitter”,  
“id”: “SenTinaSmith”  
}  
]  
}  
]  
}

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [July 5, 2021, 2:39pm UTC](https://community.thunkable.com/t/how-to-iterate-through-json-results-and-display/1380052/2 "2021-07-05T14:39:09Z")

</div>

Check this

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/8/8/886767b3e9ca4ce29ff829454953f8a94bdeaf68.png)

---

<div class="post-metadata">

### Author: ![mpokrzywinskimc6ua](https://avatars.discourse-cdn.com/v4/letter/m/a587f6/32.png) [@mpokrzywinskimc6ua](https://community.thunkable.com/u/mpokrzywinskimc6ua)
#### Post date: [July 5, 2021, 3:01pm UTC](https://community.thunkable.com/t/how-to-iterate-through-json-results-and-display/1380052/3 "2021-07-05T15:01:13Z")

</div>

Thank you, @muneer! Your solution worked for me.

---

<div class="post-metadata">

### Author: ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)
#### Post date: [November 8, 2024, 1:19pm UTC](https://community.thunkable.com/t/how-to-iterate-through-json-results-and-display/1380052/4 "2024-11-08T13:19:56Z")

</div>


