Sono completamente nuovo in Java. Sto cercando di visualizzare i dati JSON, per questo ho deciso di andare per la libreria di Jackson. Ma sto ricevendo l'errore.
Sto usando
jackson-annotations-2.3.0.jar
jackson-core-2.4.2.jar
jackson-databind-2.4.2.jar
Questo è il mio oggetto e in questo io ho una dipendenza "tnStudentLocLog" classe
public class Student implements java.io.Serializable, WorkItem {
private int studentId;
private Date date;
private Date startTime;
private Date endtime;
private int room;
private Set tnStudentLocLog;
public Student() {
}
public Student(int studentId,Date date, int room, Date startTime, Date endtime) {
this.studentId = studentId;
this.date = date;
this.room = room;
this.startTime = startTime;
this.endtime = endtime;
}
}
UserController:
@Controller
@RequestMapping(value="/students")
public class StudentController {
private static Logger logger = Logger.getLogger(StudentController.class);
private StudentManagerDelegate studentDelegate;
public StudentController() throws Exception
{
studentDelegate= new StudentManagerDelegate(ServiceType.LOCAL);
}
/********* GET ALL STUDENTS ************/
@RequestMapping(method=RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)
public @ResponseBody SuccessResponse<List<Student>> getAllStudents() throws Exception {
Map<String,List<Student>> studentsMap = new HashMap<String,List<Student>>();
SuccessResponse<List<Student>> resp = new SuccessResponse<List<Student>>();
resp.list = studentDelegate.load();
return resp;
}
Ecco, sto ottenendo il risultato corretto. Ma, "StudentID": 2 in sé è un loop come qui di seguito
{"max":"30","list":[{"studentId":2,"date":1339327730000,"startTime":1339327806000,"endtime":1339329470000,"room":0,"tnStudentLocLog":
[{"id":"studentId":2,"inTime":1339327872000},"sequenceId":2,"outTime":1339327967000,"Student":{"studentId":2,"date":1339327730000,"startTime":1339327806000,"endtime":1339329470000,"tnStudentLocLog":[{"id":{"studentId":2,"room":10,"inTime":1339327872000},"sequenceId":2,"outTime":1339327967000,"Student":{"studentId":2,"date":1339327730000,"startTime":1339327806000,"endtime":1339329470000,"tnStudentLocLog":[{"id":.......
Ma, Nell'URL quando entro "/ studenti/4". Sta visualizzando correttamente. Non so cosa sta succedendo esattamente. Ho visto molti post, stanno cambiando versioni del nucleo di Jackson, annotazioni. Ma non funziona nel mio caso.
Grazie in anticipo per il vostro aiuto.
Ancora non funziona .. – NNR
Quale problema stai affrontando ora? – gprathour
In realtà, esiste una mappatura con un'altra tabella "tnPatientLocLog". a causa di ciò è in loop i dati JSON – NNR