Java 使用接口反序列化gson,需要澄清
给定 以及位于Java 使用接口反序列化gson,需要澄清,java,gson,Java,Gson,给定 以及位于externalConfigFile的json文件,I DefaultAConfig implements AConfig DefaultLConfig implements LConfig DefaultConfiguration implements Configuration Json结构如下所示: DefaultConfiguration{config={k1=23, k2=word}, sectionL=sectionL{default_level='null', im
externalConfigFile
的json文件,I
DefaultAConfig implements AConfig
DefaultLConfig implements LConfig
DefaultConfiguration implements Configuration
Json结构如下所示:
DefaultConfiguration{config={k1=23, k2=word}, sectionL=sectionL{default_level='null', impl='null', levels=[]}, sectionA=[DefaultAConfig{format='null', filename='null', rotation='null', threshold=null}, DefaultAConfig{format='null', filename='null', rotation='null', threshold=null}]}
为什么
sectionA
和sectionL
的内容没有设置呢?只是关于lib的一个注释:在你的情况下,我会使用解析器而不是Gson。但这是一个品味问题。请向我们展示DefaultConfiguration.java
DefaultConfiguration{config={k1=23, k2=word}, sectionL=sectionL{default_level='null', impl='null', levels=[]}, sectionA=[DefaultAConfig{format='null', filename='null', rotation='null', threshold=null}, DefaultAConfig{format='null', filename='null', rotation='null', threshold=null}]}
{
"config": {
"k1": "23",
"k2": "word"
},
"sectionL": {
"default_level": "whatever",
"impl": "whatever",
"levels": [
"a",
"b"
]
},
"sectionA": [
{
"format": "text",
"filename": "/a/b/c",
"rotation": "asdasd",
"threshold": "isdals"
} ,
{
"format": "text",
"filename": "/a/b/d",
"rotation": "asdasd",
"threshold": "isdals"
}
]
}