我是一名android初学者,请对此进行必要的帮助。获取异常:org.json.JSONObject无法转换为JSONArray
try {
JSONArray jArray = new JSONArray(result);
// Extract data from json and store into ArrayList as class objects
for (int i = 0; i < jArray.length(); i++) {
JSONObject json_data = jArray.getJSONObject(i);
DataFish fishData = new DataFish();
fishData.nonce = json_data.getString("nonce");
fishData.iUserId = json_data.getString("iUserId");
fishData.timestamp = json_data.getString("timestamp");
fishData.token = json_data.getString("token");
data.add(fishData);
}
// Setup and Handover data to recyclerview
mRVFishPrice = (RecyclerView) findViewById(R.id.fishPriceList);
mAdapter = new AdapterFish(PostActivity.this, data);
mRVFishPrice.setAdapter(mAdapter);
mRVFishPrice.setLayoutManager(new LinearLayoutManager(PostActivity.this));
}
catch (JSONException e) {
Toast.makeText(PostActivity.this, e.toString(), Toast.LENGTH_LONG).show();
}
我把它转换成JSONArray还是我越来越
org.json.JSONException:值{ “代码”: “0”, “消息”:“访问被拒绝, 无效用户参考“}类型org.json.JSONObject不能被 转换为JSONArray。
发布您的JSON数据。 –
首先检查你的代码是o还是1.如果代码1得到数组值 – vinoth12594
使用代码键整数 – vinoth12594