我有一个 json 文件
{
"l": {
"default_level": "...",
"impl": "...",
"levels": [
...,
...
]
},
"a": [
{
"format": "...",
"filename": "...",
"rotation": "...",
"ls": [
...,
...
]
}
]
}
我试图映射到
public class ABC {
private List<A> aList = new ArrayList<>();
private L lConfig = new L();
// Gettters and Setters for aList and l
public static class L {
String default_level;
String impl;
List<String> levels = new ArrayList<>();
// Gettters and Setters
@Override
public String toString() {
// ...
}
}
public static class A {
String format;
String filename;
String rotation;
List<String> ls = new ArrayList<>();
// Getters and Setters
@Override
public String toString() {
// ...
}
}
}
正在反序列化
public static BLAH load(String externalConfigFile) throws IOException {
ABC config = null;
Path path = Paths.get(externalConfigFile);
if (Files.exists(path) || Files.isReadable(path)) {
config = new Gson().fromJson(readFile(externalConfigFile), ABC.class);
}
return config;
}
哪个,在印刷时给了我
A[]
L{default_level='null', impl='null', levels=[]}
为什么东西没有设置?