Unable to Loop through dynamic json string recursively in android

余生长醉 提交于 2019-11-26 18:01:59
Pararth

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)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!