I'm getting an API in my application that returns an Array of names, I've created a class to assign each name to 1 instance but I'm having trouble getting this JSONArray and turning it into object, all the methods I've tried do not Did they work, does anyone know how to do this in Java (Android)?
public void jsonToObj(JSONArray resultadoDaPesquisa) {
try {
JSONObject jsonObject = null;
JSONArray jsonArray = resultadoDaPesquisa;
jsonObject = new JSONObject(resultadoDaPesquisa.toString());
System.out.println("resultado " + jsonObject);
} catch (Exception e) {
e.printStackTrace();
}
}
org.json.JSONException: Value [{"id": 67377, "name": "Shiren the Wanderer 4: The Eye of God and the Devil's Navel"}] of type org.json.JSONArray can not be converted to JSONObject