Is there a way to convert JSON Array to normal Java Array for android ListView data binding?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How can I create this custom Bottom Navigation on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
I know that question is about JSONArray but here's example I've found useful where you don't need to use JSONArray to extract objects from JSONObject.
Works also with array of strings
Use can use a
String[]
instead of anArrayList<String>
:It will reduce the memory overhead that an ArrayList has
Hope it helps!
Maybe it's only a workaround (not very efficient) but you could do something like this:
String[] resultingArray = yourJSONarray.join(",").split(",");
Obviously you can change the '
,
' separator with anything you like (I had aJSONArray
of email addresses)Here is a better way of doing it: if you are getting the data from API. Then PARSE the JSON and loading it onto your listview:
Instead of using bundled-in
org.json
library, try using Jackson or GSON, where this is a one-liner. With Jackson, f.ex: