获得一个JSONException:输入端的字符0 [英] Getting a JSONException: end of input at character 0
问题描述
我在PHP的API,将数据发送JSON格式。 我做了如下code,当我在无线工作正常。 但是,当我想从API,当我在3G下载数据时,我收到以下异常: JSONException:输入的字符0结束
I have an API in php, that sends data in JSON format. I made the following code, that works fine when I am on wifi. But when I want to download the data from the API when I am on 3g, I receive the following exception: JSONException: End of input at character 0 of
我不知道为什么它在无线工作,但它不会对移动互联网。 我的code:
I have no idea why it does work on wifi, but it doesn't on mobile internet. My code:
JSONObject json = getJSONfromURL("http://api.myurl.com/users.json");
JSONArray objects = json.getJSONArray("objects");
db.setLockingEnabled(false);
db.beginTransaction();
for (int i = 0; i < objects.length(); i++) {
JSONObject e = objects.getJSONObject(i);
if(e.getString("UID") != "-1"){
ContentValues values = new ContentValues();
//DO DATABASE INSERT. REMOVED THIS CODE FOR READABILITY
alldata_mProgressDialog.incrementProgressBy(1);
}
}
任何人都可以帮助我吗?
Anyone that can help me out?
推荐答案
你可能得到一个空白的响应。它不为空,但反应是空的。所以,你得到这个错误,而不是一个空指针异常
You are probably getting a blank response. Its not null but the response is empty. So you are getting this error and not a Nullpointer exception
这篇关于获得一个JSONException:输入端的字符0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!