Skip to content Skip to sidebar Skip to footer

Optimize Jsonarray For Loop

Today, I'm trying to optimize my JSONArray regarding android developer documentation. I was supposed to optimize it but there is error message coming out. JSONArray infojson = json

Solution 1:

You can't use JSONArray with the that syntax as it doesn't implement Iterable interface. As a side note, the micro performance improvement you get probably won't affect your application performance as JSON results that are returned from the WebService are typically not large in size.

Solution 2:

You're getting that error because JSONArray doesn't implement the Iterableinterface.

In short, there's no clean way to solve this; you'd have to serialize the JSONObjects into your custom class.

To save you time though, using (Object one: all) over (i=0; i < all.getLength(); i++) won't give you any runtime improvements.

Just stick to the normal for loop.

Post a Comment for "Optimize Jsonarray For Loop"