JSONは初めてです。JSONで文字列を読み取ろうとしていますが、エラーが発生します。
String strResponse = "{"IndustryList" : [{"industryId" : "1","industryName" : "Bird Nest","industryStatus" : "0","industryDescription" : "Bird nest industry","industryIconFilepath" : "","industryIconFilename" : ""},{"industryId" : "2","industryName" : "Medicine","industryStatus" : "0","industryDescription" : "Medicine Products","industryIconFilepath" : "","industryIconFilename" : ""}]}"
JSONObject json_data = new JSONObject(strResponse);
JSONArray nameArray = json_data.names();
JSONArray valArray = json_data.toJSONArray(nameArray);
Log.i(MainActivity.class.getName(),
"Number of entries " + valArray.length());
for (int i = 0; i < valArray.length(); i++) {
JSONObject jsonObject = valArray.getJSONObject(i);
Log.i(MainActivity.class.getName(), jsonObject.getString("text"));
}
エラー:
at 0 of type org.json.JSONArray cannot be converted to JSONObject