【发布时间】:2019-09-09 09:09:45
【问题描述】:
如何使用改造在 android 中调用动态嵌套 json 对象。我有以下格式的 JSON 结果,我的问题是:我如何访问“类别”的内容,因为“食物”、“时尚”等是所有动态值?给我一个想法。
{
"offer": {
"id": "JUN_HAIR_1302177631",
"categories": {
"electronics": {
"address_1": "12 Mott St",
"address_2": null,
"city": "New York",
"cross_streets": "Chatham Sq & Worth St",
"state": "NY",
"zip": "10013"
},
"food": {
"address_1": "12 Mott St",
"address_2": null,
"city": "New York",
"cross_streets": "Chatham Sq & Worth St",
"state": "NY",
"zip": "10013"
},
"fashion": {
"address_1": "12 Mott St",
"address_2": null,
"city": "New York",
"cross_streets": "Chatham Sq & Worth St",
"state": "NY",
"zip": "10013"
},
.........
.........
}
}
}
【问题讨论】:
-
请贴出你试过的代码。
-
给我一个开始的想法
-
理想情况下,类别应该是一个 json 数组,并且内部对象需要有类似 category_name: xyz ..... 这将使模型更容易建模并且更动态
标签: java android json kotlin retrofit2