I'm trying to convert the JSON data that i get back to an array so I can use the data in a listView.
I got the following code:
JSONObject jsonobject;
jsonobject = JSONFunctions.getJSONfromURL("example/url");
ArrayList<String> list = new ArrayList<String>();
JSONArray jsonArray = (JSONArray)jsonobject;
if (jsonArray != null) {
//do something with it
}
Note: I don't have any experience with Java.
The method getJSONfromURL returns the JSON of the given URL that works just fine but the error is in JSONArray jsonArray = (JSONArray)jsonobject;
It gives the following error: cannot cast JSONObject to JSONArray
I've also tried this: JSONArray jsonArray = (JSONObject)(JSONArray)jsonobject;
I can't figure out what i'm doing wrong.
So how can I cast my jsonobject to a normal array that I can use as data for my listView?
JSONFunctions.new JSONArray(String).