0
我有一個json對象,如下所示。解析具有兩種格式對象的json
{
"products": [
{
"details": {
"name": "xxx",
"price": "100rs"
},
"description": "Buy this product"
}, {
"details": [{
"name": "yyy",
"price": "200rs"
}],
"description": "another project"
}
]
}
這裏的details
以兩種格式呈現。我如何創建一個POJO(普通舊Java對象)類用於Retrofit api?
不是Java專家,但我猜你不能有一個類中相同名稱的兩個領域。至少應該是「細節」和其他「細節」。 –
使用這個在線工具,希望對你有幫助.. http://pojo.sodhanalibrary.com/ –
我認爲你可以寫這樣一個自定義的反序列化器:http://stackoverflow.com/questions/35502079/custom- converter-for-retrofit-2 – nasch