简体   繁体   English

错误org.json.JSONObject无法转换为JSONArray

[英]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.

相关问题 org.json.JSONObject无法转换为JSONArray - org.json.JSONObject cannot be converted to JSONArray 无法将org.json.JSONObject类型的数据转换为JSONArray - Data of type org.json.JSONObject cannot be converted to JSONArray 类型为org.json.JSONObject的响应无法转换为JSONArray - at response of type org.json.JSONObject cannot be converted to JSONArray at 类型 org.json.JSONObject 的数据无法转换为 JSONArray - at data of type org.json.JSONObject cannot be converted to JSONArray 值类型 org.json.JSONObject 无法转换为 JSONArray - Value type org.json.JSONObject cannot be converted to JSONArray 我有一个错误:类型 org.json.JSONObject 无法转换为 JSONArray - I have an error : type org.json.JSONObject cannot be converted to JSONArray 解析JSON数组时,获取异常“ org.json.JSONObject类型的答案无法转换为JSONArray” - Getting exception “ at answer of type org.json.JSONObject cannot be converted to JSONArray” while parsing JSON array 在Android中解析JSON响应“无法将org.json.JSONObject类型的响应转换为JSONArray” - Parse JSON response in android “response of type org.json.JSONObject cannot be converted to JSONArray” org.json.JSONException:值 {“storeid0”:[“1535”],“storeid1”:[“1862”]} 类型为 org.json.JSONObject 的 idddsss 无法转换为 JSONArray - org.json.JSONException: Value {“storeid0”:[“1535”],“storeid1”:[“1862”]} at idddsss of type org.json.JSONObject cannot be converted to JSONArray 无法将类型为org.json.JSONObject $ 1的值null转换为JSONObject错误 - Value null of type org.json.JSONObject$1 cannot be converted to JSONObject error found
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM