我正在连接MySQL数据库与我的SQLite和Android。我得到JSON对象错误。它抛出了org.json.Exception。
try
{
JSONObject json_data = new JSONObject(result);
name=(json_data.getString("name"));
Toast.makeText(getApplicationContext(), "Name : "+name,
Toast.LENGTH_SHORT).show();
}
catch(Exception e)
{
Log.e("Fail 3", e.toString());
}
查看结果字符串,它不是JSON而是XML文件。
您的响应是XML格式,在您的服务器端使用json_encode(data)