good morning I'm doing an application with Android Studio 3.0.1 with a mysql database and at the time of the query it returns me a json and at the moment of that comes to the app returns me
["2", "Example2", "Author2", "Editorial2", "Faculty2", "0"] ["7", "Example2", "Author4", "Editorial4", "Faculty5", " 0 "]
the response but when passing it to a JSONArray it only gives me the first part of the result
["2", "Example2", "Author2", "Editorial2", "Faculty2", "0"]
but I do not know what the error is because it does not give me the result as I want it, I am new programming and if you can tell me what I am doing wrong or where or how to look for information I will be grateful annex my code
private void ConsultaTitulo(String URL) {
RequestQueue queue = Volley.newRequestQueue(this);
StringRequest stringRequest = new StringRequest(Request.Method.GET, URL, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
String a;
Log.d("Json responda",response);
ja = new JSONArray(response);
String contra = ja.getString(0);
Log.d("Json responda",response);
for (int i = 0; i < ja.length(); i++)
{
JSONObject jsonObj = ja.getJSONObject(i);
Log.d("Json responda", String.valueOf(jsonObj.get("id")));
}
// Log.d("Json responda",contra);
}catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
queue.add(stringRequest);
}
Error
04-11 05: 34: 48.826 4349-4349 / com.example.ferney.bibliotecacur D / Json answer:
["2", "Example2", "Author2", "Editorial2", "Faculty2", "0"] ["7", "Example2", "Author4", "Editorial4", "Faculty5", "0"] 04-11 05: 34: 48.826 4349-4349 / com.example.ferney.bibliotecacur D / Json answer:
["2", "Example2", "Author2", "Editorial2", "Faculty2", "0"] ["7", "Example2", "Author4", "Editorial4", "Faculty5", "0"] 04-11 05: 34: 48.870 4349-4349 / com.example.ferney.bibliotecacur W / System.err: org.json.JSONException: Value 2 at 0 of type java.lang.String can not be converted to JSONObject 04-11 05: 34: 48.872 4349-4349 / com.example.ferney.bibliotecacur W / System.err: at org.json.JSON.typeMismatch (JSON.java:100) 04-11 05: 34: 48.872 4349-4349 / com.example.ferney.bibliotecacur W / System.err: at org.json.JSONArray.getJSONObject (JSONArray.java:525)