Please take a look at this javascript code inside a GSP(similar to JSP):
var json =JSON.parse("${savedkpiz.get(0).kpi.replace("\"","\\\"")}")
savedkpiz(list object) object is sometimes have no element so access at 0 will throw NPE, how can i prevent this code from executing?? JavaScript if else seems not working
var json =JSON.parse("${if(savedkpiz.size()>0) ? savedkpiz.get(0).kpi.replace("\"","\\\""):""}")
above code too not working?? how can i put condition on this and at the same time if true then populate json variable.
Please help guyz, thanks in advance