Sto cercando di analizzare JSON da Android ma ottengo questa strana eccezione. I miei dati JSON èorg.json.JSON Eccezione: fine dell'input al carattere 0
{ "id": "1", "proprietario": "1", "name": "gravitas", "Descrizione": "è una festa", "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": "tipo", "ownername": "dilip", "noofpolls": 0, "noofquizes": 0, "peopleattending": 0, "risultato": true }
e in Android faccio
JSONObject j =new JSONObject(response);
Event pst = gson.fromJson(j.toString(), Event.class);
ottengo:
org.json.JSONException: end of input at character 0 of
Cosa c'è di sbagliato in questo? Ecco il codice ...
RestClient client = new RestClient("http://192.168.1.3/services/events/"+eve.getName());
try {
Log.i("MY INFO", "calling boston");
client.Execute(RequestMethod.POST);
} catch (Exception e) {
e.printStackTrace();
}
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
e.printStackTrace();
}
Ciao Rakon_188, sto anche ricevendo lo stesso problema .. ma ci sto provando in un modo diverso .. puoi mandarmi il codice completo .. – wolverine
Aveva lo stesso problema qui, ma sembra che dovessi cambiare il mio al POST anziché GET. Sembra che questo errore venga generato se hai semplicemente sbagliato, quindi potresti dover semplicemente cambiare la chiamata. – Silmarilos
grazie uomo: * ... –