我有这样的凌空onResponse:JSONArray不能申请为java.lang.String
public void onResponse(String response) {
try {
JSONArray info = new JSONArray(response);
String name = info.getString("name");
String picture = info.getString("picture");
Picasso.with(context).load(picture).into(profile);
user_name.setText(name);
} catch (JSONException e) {
e.printStackTrace();
Toast.makeText(getApplicationContext(), "Error: " + e.getMessage(), Toast.LENGTH_LONG).show();
}
}
问题是("name")
和("picture")
给我JSONArray不能申请为java.lang.String。
我错过了什么?
编辑:
[{"name":"josh","picture":"http:\/\/192.168.0.11\/pic.png"}]
你可以分享响应JSON,看起来像“名称”和“图片”值也是JSONArray,而不仅仅是字符串。 – Shubham
@Shubham它是这样的:'[{“name”:“josh”,“picture”:“http:\/\/ip \ /pic.png”}]' –
你不是在循环阵列! –