I have a View Component which has a ListView filled with JSON data. I use FLUX Pattern for my DataFlow. Now when i get a JSON response, "_userNews", which has multiple arrays, with objects inside each array, how is the best way to print out my ListView items? The Objects contains one array and 4 strings. I need the array items from the object as well as 2 strings which i would like to print out in my ListView. I am a noob in programming and just trying to struggle through the programmers world and learning. Maybe someone has a hint for me how to work with Arrays/Objects.
Asked
Active
Viewed 47 times
1 Answers
0
Some tips:
Use GSON to map your JSON to a class model. Eg: Json to Gson - Modeling
Use the model's toString or a new api toListItemString to be used with ListView.
class Thing { String id; String name; String notRequired; List<String> object2; public String toListItemString(){ return this.id + "\n" + this.name + "\n" + Arrays.toString(object2); } }
Do share a sample JSON for more specific response.
-
Does this work for React Native too? I used GSON in my Android / Java Project a long time ago, but didn´t know that this works for JavaScript too... – BigPun86 Nov 10 '15 at 10:45
-
Not sure if I understood it correctly. For GSON/JS I found a link: http://stackoverflow.com/questions/22777930/javascript-gson-access-json-references-dynamically-over-object-graph-circular – thepace Nov 11 '15 at 10:55