You mean to say i need to create somthing like -
JSONObject json = new JSONObject();
and then try to access that in my Ajax call. as i am using Spring controller, should i have to put this json abject in following format -
mav.addObject("data", json); (where mav is ModelAndView mav = new ModelAndView("jsonView");)
Just return the Map in your Controller and annotate it with @ResponseBody.
have <mvc:annotation-driven/> in your Spring config and just include the Jackson jar file. Apache Jackson is a great JSON library for Java. You just need it in your classpath for Spring to automatically convert the Map into JSON.
In your results, it looks like the map has some objects in which it seems to be just calling the default toString of that object. Jackson instead will "serialize" the data in the object's properties into JSON.