Android:dynamically pass model class to retrofit callback

后端 未结 10 1799
伪装坚强ぢ
伪装坚强ぢ 2020-12-05 04:34

In retrofit to map json response to pojo usually we do this

@POST
Call getDataFromServer(@Url String url, @Body HashMap ha         


        
10条回答
  •  孤街浪徒
    2020-12-05 05:10

    My approach is make a POJO called ResponseData in which you will have an attribute Object, so you have:

    @POST
    Call getDataFromServer(@Url String url, @Body HashMap hashMap);
    

    When you get the response you have to parse your response.body() to the desired class. So the pros: you just have one request, instead you have to parse the response.

提交回复
热议问题