【发布时间】:2018-10-29 06:19:44
【问题描述】:
我想从 'number' 和 'step' 属性中获取数据,但似乎找不到解决方案。我是android的初学者,非常感谢您的帮助
**这里是json ** https://api.myjson.com/bins/135pdu
这是我的代码
JsonArrayRequest request = new JsonArrayRequest(Request.Method.GET, uri,null,
new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
String count,step;
try {
Log.d("VolleyResponse","Response:" + response);
for(int i = 0; i<response.length();i++){
JSONObject current = response.getJSONObject(i);
JSONArray arrayStatus = current.getJSONArray("steps");
for(int a = 0; a<arrayStatus.length(); a++){
JSONObject recipe_step = arrayStatus.getJSONObject(i);
count = recipe_step.getString("number");
step = recipe_step.getString("step");
steps.append("Step " +count+":"+step+"\n\n");
}
}
}catch(JSONException e){
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.e("VolleyError", error.toString());
}
【问题讨论】:
标签: android api android-volley