Unable to Loop through dynamic json string recursively in android

Did you debug and check where exactly does it break?

Use a for each loop where you can instead of for(;;)

http://docs.oracle.com/javase/1.5.0/docs/guide/language/foreach.html

How does the Java ‘for each’ loop work?

Also, If you have a complicated json, you may be better off using Gson to map data and your model classes. Eg.:

    Gson gson = new Gson();
    ModelClass modelClass= new ModelClass();
    modelClass= gson.fromJson(responseContent,ModelClass.class); 
//where responseContent is your jsonString
    Log.i("Web service response", ""+modelClass.toString());

https://code.google.com/p/google-gson/

For Naming discrepancies(according to the variables in webservice), can use annotations like
@SerializedName. (So no need to use Serializable)

Leave a Comment