Handle different JSON response types from same endpoint in RetroFit

前端 未结 3 660
悲&欢浪女
悲&欢浪女 2021-01-17 16:04

I need help.

I have an endpoint that takes a parameter. Depending on this parameter, the JSON returned will be completely different.

Is it possi

3条回答
  •  囚心锁ツ
    2021-01-17 17:03

    In this response, since it is only change in the fields but not the structure like array or object. In that case just define all the fields in the java object, the values that will be returned in that specific call will be mapped and the others will be null. Put a logic on your end to check null checks.

提交回复
热议问题