Get nested JSON object with GSON using retrofit

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

    Another simple solution:

    JsonObject parsed = (JsonObject) new JsonParser().parse(jsonString);
    Content content = gson.fromJson(parsed.get("content"), Content.class);
    

提交回复
热议问题