Rakon_188 Rakon_188 - 1 year ago 173
JSON Question

org.json.JSON Exception : End of input at character 0

i'm trying to parse json from android but i get this strange exception. my json data is

{"id":"1","owner":"1","name":"gravitas","description":"is a fest","start_time":"0000-00-00 00:00:00","end_time":"0000-00-00 00:00:00","venue":"vellore","radius":"10","lat":"11","lng":"11","type":"type","ownername":"dilip","noofpolls":0,"noofquizes":0,"peopleattending":0,"result":true}

and in android i do

JSONObject j =new JSONObject(response);
Event pst = gson.fromJson(j.toString(), Event.class);

i get:

org.json.JSONException: end of input at character 0 of

What's wrong with it? heres the code...

RestClient client = new RestClient(""+eve.getName());
try {
Log.i("MY INFO", "calling boston");
} catch (Exception e) {

String response = client.getResponse();
Log.i("MY INFO", response);
GsonBuilder gsonb = new GsonBuilder();
Gson gson = gsonb.create();
Event pst = null;

try {
JSONObject j =new JSONObject(response);
pst = gson.fromJson(j.toString(), Event.class);

} catch (JSONException e) {
// TODO Auto-generated catch block

Answer Source

oops my bad i was supposed to use GET method.that url doesnt respond to POST requests so i was getting the org.json.JSON Exception : End of input at character 0.its because of this i got null response which generated that exception.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download