我正在尝试拼合以下Json
[
{
"type": 1,
"field": ""
},
{
"type": 2,
"field": "",
"other_field": ""
},
{
"type": 3,
"field": "",
"list_field": [
{
"type": 4,
"some_field": ""
},
{
"type": 4,
"some_field": ""
}
]
}
]
我想要获得的是以下结构:
[
{
"type": 1,
"field": ""
},
{
"type": 2,
"field": "",
"other_field": ""
},
{
"type": 3,
"field": ""
},
{
"type": 4,
"some_field": ""
},
{
"type": 4,
"some_field": ""
}
]
由于所有项目均从同一个父类继承,因此我尝试了PolymorphicJsonAdapterFactory和自定义的JsonAdapter.Factory,但均未成功。
在Moshi中有办法做到这一点吗?