获取对象整数 json 到 android studio
get object integer json to android studio
json with int key value
我被卡住了,像这样调用 json 到 android studio 使用 volley,我以前从未这样做过
据此json with int key value
你是
receiving jsonArray instead of jsonObject
所以你必须
send the request of JsonArray with volley
然后请求将 return jsonArray 然后你可以像这样得到你的字符串。
JsonArrayRequest jsonArrayRequest = new JsonArrayRequest("url", new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response)
{
try
{
for (int i=0;i<response.length();i++)
{
JSONArray jsonArray = response.getJSONArray(i);
for (int j=0;j<jsonArray.length();j++)
{
String yourString = jsonArray.getString(j);
// you can convert it into int as per your requirement
}
}
} catch (JSONException e)
{
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error)
{
}
});
json with int key value
我被卡住了,像这样调用 json 到 android studio 使用 volley,我以前从未这样做过
据此json with int key value 你是
receiving jsonArray instead of jsonObject
所以你必须
send the request of JsonArray with volley
然后请求将 return jsonArray 然后你可以像这样得到你的字符串。
JsonArrayRequest jsonArrayRequest = new JsonArrayRequest("url", new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response)
{
try
{
for (int i=0;i<response.length();i++)
{
JSONArray jsonArray = response.getJSONArray(i);
for (int j=0;j<jsonArray.length();j++)
{
String yourString = jsonArray.getString(j);
// you can convert it into int as per your requirement
}
}
} catch (JSONException e)
{
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error)
{
}
});