Get nested JSON object with GSON using retrofit

前端 未结 13 979
挽巷
挽巷 2020-11-22 17:04

I\'m consuming an API from my android app, and all the JSON responses are like this:

{
    \'status\': \'OK\',
    \'reason\': \'Everything was fine\',
    \         


        
13条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-22 17:34

    A better solution could be this..

    public class ApiResponse {
        public T data;
        public String status;
        public String reason;
    }
    

    Then, define your service like this..

    Observable> updateDevice(..);
    

提交回复
热议问题