我不知道我做错了什么,但是从json到我的POJO的转换是行不通的。我更新了依赖项。当我调用方法“readJSONFromURL”时,我的返回始终是具有值为NULL的属性的对象。所有的库都是最新的。
我的对象:
public class ListHall {
private List<Hall> Hall;
public void setHall(List<Hall> hall) {
this.Hall = hall;
}
public List<Hall> getHall() {
if (Hall == null) {
this.Hall = new ArrayList<Hall>();
}
return Hall;
}
}
public class Hall {
private String id;
private String name;
private Integer count;
//getter and setters here
}
我的DataMappers:
data_mapper ListHall:ListHallMapper
data_mapper Hall:HallMapper
我的方法转换:
public ListHall mapHall() throws IOException {
ListHallMapper returnListHallMapper = new ListHallMapper();
HallMapper hallMapper = new HallMapper();
DataMapper.createContext(Arrays.asList(returnListHallMapper,
hallMapper),
(DataMapper mapper) -> {
mapper.setReadKeyConversions(Arrays.asList(DataMapper.CONVERSION_CAMEL_TO_SNAKE));
});
return returnListHallMapper.readJSONFromURL("http://192.168.0.16:7080/integration/hall", ListHall.class,"/ListHall");
}
我的输出JSON:
{“ListHall”:{“Hall”:[{“id”:“0”,“name”:“Salão1”,“count”:“10”},{“id”:“ f6a495c1-be5e-4476-a362-5d42e572bfae“,”name“:”Salão3“,”count“:”0“}]}}
我做错了什么?