改造-是否可以进行嵌套的HTTP请求?

时间:2019-05-09 10:00:29

标签: android json retrofit retrofit2 android-room

我使用的私有API具有我从未见过的设计。

假设我们有以下Json:

{
"id": 2,
"name": "Test Customer",
"company": "/customer/company/10",
"contacts": [
    "/contact/12"
],
"created_at": "2019-06-21T00:00:00+02:00",
"updated_at": "2019-06-21T00:00:00+02:00",
"created_by": "/user/1"
}

您会注意到,“ contacts”和“ created_by”字段只是String格式的查询。

但是,在API文档中说:

  • “联系人”类型为“联系人” []

  • “ created_by”的类型为用户。

我对字段应该是User和Contacts []对象感到困惑,但是在JSON中它返回一个String。是否可以先将其存储为字符串,然后再存储为用户对象(例如,使用Gson)。

enter image description here

我可以采用什么方法来解析这个Json?

0 个答案:

没有答案