Is it possible to use retrofit without model class?

前端 未结 5 1169
时光说笑
时光说笑 2021-01-02 02:38

i have problem to use model class in retrofit lib. A backend side field name has changed.

Is it possible to get response without model class?

5条回答
  •  爱一瞬间的悲伤
    2021-01-02 02:58

    It is perfectly possible using different return values. I assume that you currently use Gson to deserialize JSON responses, and they get converted to the actual class. However, you may choose to convert the returned response to JsonElement (or some more specific JSON class), in that case you will get a JSON item which you can manipulate as you wish to. Something like:

    @GET("url")
    Call apiCall();
    

提交回复
热议问题