我需要通过json响应树结构,
{
MyClass 1:[{MyClass 11},{MyClass 12}],
MyClass 2:[{MyClass 21},{MyClass 22}],
MyClass 3:[{MyClass 31},{MyClass 32},
{MyClass 33 :[{MyClass 331},{MyClass 332}]}
]
}
我用HashMap<MyClass, ArrayList<Object>>
来做到这一点
并且有效,但是当我通过Gson()。toJson转换为Json
显示{MyClass Format: object Format}
像这样
{
"{Id=1, Name=HQS, parentId=0, level=1}":[
{
"_Id":5,
"_Name":"ADM",
"_originalName":"ADM",
"_parentId":1,
"_originalParentId":1,
"_setOriginalParentId":false,
"_level":2,
"_originalLevel":2,
"_setOriginalLevel":false,
"_columnBitmask":0,
"_cachedModel":false,
"_new":false
},
{
"{Id=2, Name=HQS, parentId=1, level=2}":[
{
"_Id":21,
"_Name":"ADMS",
"_originalName":"ADMS",
"_parentId":2,
"_originalParentId":2,
"_setOriginalParentId":false,
"_level":3,
"_originalLevel":3,
"_setOriginalLevel":false,
"_columnBitmask":0,
"_cachedModel":false,
"_new":false
}
]
}
]
}
我想关键是对象,如何解决它以显示类格式?