Gson:序列化地图时显示类名

时间:2013-08-16 08:46:59

标签: java gson

我有一个复杂的序列化地图,比如

    Map<ClassA, Map<ClassB, Map<...>>>.  

我使用了GsonBuilder()并添加了enableComplexMapKeySerialization()。它工作正常,但就像

    [{
        "foo": "bar"
        // data of A
     },
     [
        {
           // data of B
        }
        // other information
     ]
    ]

我的问题是,有没有办法将类名添加到Json,所以看起来像

    [
     "ClassA": {
        "foo": "bar"
        // data of A
     },
     [
        {
           // data of B
        }
        // other information
     ]
    ]

0 个答案:

没有答案
相关问题