The script fetches data from phpmyadmin but android studio cause this error
of type org.json.Jsonarray cannot be converted to jsonobject
my code android
code
Advertisement
Answer
Actually you are getting JSONArray
instead of JSONObject
from your server. So, You have to parse the array first then you can get object from it.
JSONArray jsonArray = new JSONArray(response); for(int i = 0; i < jsonArray.length(); i++) { JSONObject jsonObject = jsonArray.getJSONObject(i); String id = jsonObject.getString("id"); String m_e = jsonObject.getString("M_E"); }