java - Fullcalendar and json -


i'm trying load events database. i'm using gae, java , jsp. problem in json response. if write directly in script output of json, s work correctly, ajax call no. method in java:

public void caricadati(httpservletrequest req, httpservletresponse resp)         throws servletexception, ioexception {     date start=javatimestamptodatetime(double.parsedouble(req.getparameter("start")));     date end=javatimestamptodatetime(double.parsedouble(req.getparameter("end")));     date afteraddingtenmins=new date(start.getdate() + (10 * 60000));     objectifyservice.register(appuntamento.class);     list<appuntamento> listaa= ofy().load().type(appuntamento.class).filter("d >=", start).filter("d <=", end).list();     system.out.println(listaa);     jsonobject j= new jsonobject();     for(appuntamento : listaa){         resp.setcontenttype("application/json");  // set content type of response jquery knows can expect.         resp.setcharacterencoding("utf-8");         resp.getwriter().write(utildispensatojson(a, start, end));     } } 

the method of json:

public string utildispensatojson(appuntamento k, date start, date end) {     stringbuilder sb = new stringbuilder();     try {          sb.append("[");         sb.append("{");         sb.append("id : '" + k.getid() + "' , ");         sb.append("title : '" + k.gettitolo() + "' , ");         sb.append("start : '" + k.getdata() + "' , ");         //sb.append("\"end\" : \"" + end + "\",");         sb.append("allday : false ,");          sb.deletecharat(sb.lastindexof(","));         sb.append("}");         sb.append("]");         system.out.println(sb.tostring());         return sb.tostring();     } catch (exception e) {         return "errore";     }  } 

the output of json is:

[{id : '6473924464345088' , title : 'dfsf' , start : '2014/04/25 08:30' , allday : false }]

your output json appears invalid.

the properties (id, title, start, allday) should surrounded double quotes , values string types. here use single quotes instead of double quotes.

ref: https://google-styleguide.googlecode.com/svn/trunk/jsoncstyleguide.xml#double_quotes

also can test validity of json string on website: http://jsonlint.com/


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -