【发布时间】:2015-12-02 16:16:44
【问题描述】:
我正在以 JSON 格式从 PHP 获取状态,但总是得到:
org.json.JSONException: Value 43 of type java.lang.Integer cannot be converted to JSONObject
我从 JSON 读取结果的方式
int strUserID;
......
strUserID = jsonObject.getInt("UserID");
在 php 中我使用的是:
$user_id = mysql_insert_id();
echo $user_id;
if(!$objQuery)
{
$arr['StatusID'] = "0"; // unable to create user
}
else
{
$arr['StatusID'] = "1"; // user created successfully
$arr['UserID'] = $user_id; // passing user id to android app
}
网络上的 JSON 示例:
46{"StatusID":"1","UserID":46}
但在 Android 端没有将数据转换为 json 格式,因为面临异常
我可以知道我在哪里做错了吗?
【问题讨论】:
-
您可以添加您的
json回复吗? -
发布您的 Json 数据。