[英]error org.json.JSONObject cannot be converted to JSONArray
I have a php file for my android project. 我的android项目有一个php文件。 I want it to show the array data from my php codes.
我希望它显示来自我的PHP代码的数组数据。 but it show the error like "error parsing data org.json.JSONException ... error org.json.JSONObject cannot be converted to JSONArray"
但它显示错误,例如“解析数据org.json.JSONException错误...错误org.json.JSONObject无法转换为JSONArray”
Here's the php codes : 这是php代码:
$rows = array();
$rows['nama_makanan'] = "you have yet to input";
$rows['Jtakaran'] = "-";
$data = "{food:".json_encode($rows)."}";
echo $data;
I'm guessing the error is in the php code. 我猜错误是在php代码中。 because when I try to retrieve data from mysql the program is working fine.
因为当我尝试从mysql检索数据时,程序运行正常。 I'm sorry for my bad English .
对不起我的英语不好意思。 Any help would be appreciated, thank you
任何帮助,将不胜感激,谢谢
ps : I want the data to retrieve as JSONArray because this is for expanadablelistview. ps:我想将数据检索为JSONArray,因为这是针对expanadablelistview的。
echo json_encode(array("food", $rows));
check my answer on 检查我的答案
How to decode JSON values in my Android Aplication? 如何在我的Android应用中解码JSON值?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.