echo json_encode($response)の結果は
{"error":false,"message":"Success","neededData":[{"column1":1,"column2":2,"column3":3},{"column1":4,"column2":5,"column3":6}]}
必要なのは
[{"column1":1,"column2":2,"column3":3},{"column1":4,"column2":5,"column3":6}] and save it to a JSONArray array.
JSONObject userJson = obj.getJSONObject("neededData");
JSONArray array = new JSONArray(userJson);
動作しないようです。
回答 3 件
neededDataはjsonオブジェクトでなくjson配列です あなたは間違っています
JSONObject JjsonResponse = new JSONObject(yourresponce); JSONArray data= jsonResponse.getJSONArray("neededData ");
私は次のようなコードになります。
String strjsonobj='{"error":false,"message":"Success","neededData":[{"column1":1,"column2":2,"column3":3},{"column1":4,"column2":5,"column3":6}]}'; try { JSONObject jsonObject = new JSONObject(strjsonobj); JSONArray neededData = jsonObject.getJSONArray("neededData"); } catch (JSONException e) { e.printStackTrace(); }