如果有人知道回答这个问题。
我有一个错误的JSONArray无法转换为JSONObject .. 我是新手使用这个凌空图书馆
JsonArrayRequest req = new JsonArrayRequest(URL,
new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
Log.d(TAG, response.toString());
try {
// Parsing json array response
// loop through each json object
jsonResponse = "";
for (int i = 0; i < response.length(); i++) {
JSONArray product = (JSONArray) response
.get(i);
String productId = product.getString(Integer.parseInt("productId"));
String productName =product.getString(Integer.parseInt("productName"));
String productPrice = product.getString(Integer.parseInt("productPrice"));
String productImage =product.getString(Integer.parseInt("productImage"));
jsonResponse += "productId: " + productId + "\n\n";
jsonResponse += "productName: " + productName + "\n\n";
jsonResponse += "productPrice: " + productPrice + "\n\n";
jsonResponse += "productImage: " + productImage + "\n\n\n";
}
答案 0 :(得分:0)
您获得的回复是一个字符串,您正试图将其分配给jsonArray