I have a JSON array
{ "inList" :
[
{ "cmd" : "enqueue", "name" : "job1", "pri" : 4 },
{ "cmd" : "enqueue", "name" : "job2", "pri" : 3 },
{ "cmd" : "dequeue" },
{ "cmd" : "enqueue", "name" : "job3", "pri" : 0 },
{ "cmd" : "enqueue", "name" : "job4", "pri" : 1 },
{ "cmd" : "dequeue" }
]
}
I would like to use the powerful jackson to de serialize the JSON into java object.
And I have the hit class (I think it has something wrong)
public class InList {
private String[] inList;
private LinkedList<Object> jobs;
public InList() { }
public String[] getInList() {
return inList;
}
public void setInList(String[] inList) {
this.inList = inList;
}
public LinkedList<Object> getJobs() {
return jobs;
}
public void setJobs(LinkedList<Object> jobs) {
this.jobs = jobs;
}
}
And when I try to de serialize the JSON, it just can not hit the class
ObjectMapper mapper = new ObjectMapper();
InList inList = null;
try {
inList = mapper.readValue(jsonStr, InList.class);
}
Could you help me figure out?
Thanks!
inListthat contains an array of objects. The class has andinListfield that is a list ofString.