Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用接口反序列化gson,需要澄清_Java_Gson - Fatal编程技术网

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"
        }
    ]
}