I am retrieving data from multiple tables/POJO's.I want the data in JSON format.In Pojo classes I am using @JsonProperty.Still I am not getting result Json in desired format. My result:
[["2017 Sprint 1","Android development",23/12/2016,16/01/2017]]
I want result in format {
"iteration": "2017 Sprint 1",
"project": "MDM - Core & Integration",
"isd": "23/12/2016",
"ied": "16/01/2017",
My main controller method:
@Controller
@RequestMapping("/json/retrospective")
public class MainControllerClass
{
@RequestMapping(value="{userid}", method = RequestMethod.GET,produces=MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public List<Details> getInfoInJSON(@PathVariable int userid)
{
Configuration con = new Configuration();
con.configure("hibernate.cfg.xml");
SessionFactory SF = con.buildSessionFactory();
Session session= SF.openSession();
Query test=session.createQuery("select itr.iteration_name,prj.project_name,itr.isd,itr.ied from RetrospectiveInfo retro,IterationInfo itr,ProjectInfo prj where retro.retrospective_id ="+userid+" and retro.project_id = prj.project_id and retro.iteration_id = itr.iteration_id");
List<Details> details= test.list();
session.close();
SF.close();
return details;
}
}
Class details:
public class Details
{
@JsonProperty("iteration")
private String iteration;
@JsonProperty("project")
private String project;
@JsonProperty("isd")
private Date isd;
@JsonProperty("ied")
private Date ied;
getter/setters
I have got 3 Jackson jars annotation,databind and core of latest version 2.8 in buildpath.Why I am I getting such a result??What changes do I need to make in my code??Are any jars to be added??kindly help