Get nested JSON object with GSON using retrofit

前端 未结 13 1029
挽巷
挽巷 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:42

    There is a simpler way, just consider content sub object as another class:

    class Content {
        var foo = 0
        var bar: String? = null
    }
    
    class Response {
        var statis: String? = null
        var reason: String? = null
        var content: Content? = null
    } 
    

    and now you can use Response type to deserialize json.

提交回复
热议问题