# Foreach slow on Android when looping through json object

**URL:** <https://community.thunkable.com/t/foreach-slow-on-android-when-looping-through-json-object/465467>\
**Category:** Questions about Thunkable X\
**Created:** [February 14, 2020, 10:51pm UTC](https://community.thunkable.com/t/foreach-slow-on-android-when-looping-through-json-object/465467 "2020-02-14T22:51:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Claus\_Holbech1](https://avatars.discourse-cdn.com/v4/letter/c/dbc845/32.png) [@Claus\_Holbech1](https://community.thunkable.com/u/Claus_Holbech1)\
**Post date:** [February 14, 2020, 10:51pm UTC](https://community.thunkable.com/t/foreach-slow-on-android-when-looping-through-json-object/465467/1 "2020-02-14T22:51:22Z")

</div>

I have a json array of about 1000 objects like this:  
“20701”: {  
“name”: “Hvid”,  
“colorcode”: “01”,  
“package”: “1000”,  
“value”: “0”,  
“color”: “#f7f7f6”,  
“type”: “Midi”  
},  
“20101”: {  
“name”: “Hvid”,  
“colorcode”: “01”,  
“package”: “3000”,  
“value”: “0”,  
“color”: “#f7f7f6”,  
“type”: “Midi”  
},  
“20501”: {  
“name”: “Hvid”,  
“colorcode”: “01”,  
“package”: “6000”,  
“value”: “0”,  
“color”: “#f7f7f6”,  
“type”: “Midi”  
},  
“50101”: {  
“name”: “Hvid”,  
“colorcode”: “01”,  
“package”: “2000”,  
“value”: “0”,  
“color”: “#f7f7f6”,  
“type”: “Mini”  
}  
I loop through each item in the array (With foreach), and for each object where package is 1000 i create a button with clone.  
In total it is about 60 buttons.

On iOS it takes about 7 seconds. but on Android it takes about 1 min 30 sec.

Any body knows why this is so slow on android.

---

<div class="post-metadata">

**Author:** ![paulmw](https://avatars.discourse-cdn.com/v4/letter/p/22d042/32.png) [@paulmw](https://community.thunkable.com/u/paulmw)\
**Post date:** [February 15, 2020, 2:37pm UTC](https://community.thunkable.com/t/foreach-slow-on-android-when-looping-through-json-object/465467/2 "2020-02-15T14:37:53Z")

</div>

The rendering loop is slower on your Android device, which causes it to take more time. I’m working on improving this by making the blocks less dependent on the device’s rendering loop, but it’s likely my changes won’t be released until the end of March.

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [February 15, 2020, 3:35pm UTC](https://community.thunkable.com/t/foreach-slow-on-android-when-looping-through-json-object/465467/3 "2020-02-15T15:35:34Z")

</div>

Thank you @paulmw!! I notice stuff like this too. I look forward to the fixes!!!

---

<div class="post-metadata">

**Author:** ![Claus\_Holbech1](https://avatars.discourse-cdn.com/v4/letter/c/dbc845/32.png) [@Claus\_Holbech1](https://community.thunkable.com/u/Claus_Holbech1)\
**Post date:** [February 29, 2020, 11:07pm UTC](https://community.thunkable.com/t/foreach-slow-on-android-when-looping-through-json-object/465467/4 "2020-02-29T23:07:19Z")

</div>

Now that Extended listviewer has been removed from the comming soon, then I think it is even more important to get a solution to this, as using clone to create lists needs the foreach function.

---

<div class="post-metadata">

**Author:** ![maptheunknown](https://avatars.discourse-cdn.com/v4/letter/m/f475e1/32.png) [@maptheunknown](https://community.thunkable.com/u/maptheunknown)\
**Post date:** [April 16, 2020, 6:34pm UTC](https://community.thunkable.com/t/foreach-slow-on-android-when-looping-through-json-object/465467/5 "2020-04-16T18:34:39Z")

</div>

waiting for the solution for this also.

---

<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, 11:38am UTC](https://community.thunkable.com/t/foreach-slow-on-android-when-looping-through-json-object/465467/6 "2024-11-08T11:38:55Z")

</div>


