Org.json.jsonexception: End Of Input At Character
Solution 1:
Change
JSONObject jsonObject = newJSONObject(result);
to
result=getJSONUrl(url); //<< get json string from serverJSONObject jsonObject = newJSONObject(result);
inside doInBackground
method of DownloadJSONFileAsync
because currently you are not making any post for getting Json data from the server and just trying to parse an empty string to json
Solution 2:
as you can see from this answer, you are probably getting a blank response.in general, the org.json.JSONException: End of input at character N of...
means that the JSON couldn't be parsed and something is not being done right.
if the problem is that you're getting a blank response, you should make sure you get a response from the server before trying to parse it (like ρяσѕρєя K's answer).
if the problem is a bad JSON, you should try and validate it. JSONLint is a very good place to start.
Solution 3:
I'm not seeing you assign anything to result after this String result = "";
in here pastebin.com/mNVGEnD5
and if you trying to get json object with this
JSONObject jsonObject = newJSONObject(result);
it'll surely return end of input at character 0 because the string result is empty maybe you can try to replace it with some jsonString you can use this as an example :
{"result":"OK","member_id":"32","first_name":"Android","last_name":"JSON","nickname":"HEY","accesskey":"123556332","facebook_id":"0","facebook_token_expire_date":"0000-00-00 00:00:00","facebook_token_expire_date2":"0000000000000","facebook_token_refresh_date":"0000-00-00 00:00:00","facebook_token_key":"null","status_active":1}
Solution 4:
Please check PHP File URL in Browser if get the data means you have problem in android side if browser not shows the data it means problem in PHP file.
Solution 5:
-please check your all json veriables are properly return only json format or not.
- Don’t use "http://localhost" or "http://127.0.0.1". Use "http://10.0.2.2" instead.
Post a Comment for "Org.json.jsonexception: End Of Input At Character"