改造模型对象

Retrofit model object

我是 Retrofit 的新手。我需要为下面的 JSON 查询创建一个 Parcelable 模型对象,但似乎无法让它工作。鉴于下面的 JSON 中有两个 id 属性,我有点困惑。任何帮助都会很棒。

JSON查询

   {"id":83542,"page":1,"results":[{"id":"51910979760ee320eb020fc2","author":"Andres Gomez","content":"Interesting film with an exceptional cast, fantastic performances and characterizations. The story, though, is a bit difficult to follow and, in the end, seems to not have a real point.","url":"https://www.themoviedb.org/review/51910979760ee320eb020fc2"},{"id":"520a8d10760ee32c8718e6c2","author":"Travis Bell","content":"Cloud Atlas was a very well made movie but unlike most of the \"simultaneous stories that all come together at the end\" type of movies, this one just didn't. I'm still unclear as to the point of it all.\r\n\r\nAnother issue I had was a general feeling of goofiness. Sure, the Cavendish story was pure comedy but the rest of the stories just didn't feel serious enough to me.\r\n\r\nIt carried my attention for the 172 minutes well enough and it was entertaining. I just expected more of a pay off at the end.\r\n\r\nAll in all, it's definitely worth seeing but I still haven't made up my mind if I truly liked it or not. What did you think?","url":"https://www.themoviedb.org/review/520a8d10760ee32c8718e6c2"}],"total_pages":1,"total_results":2}

为您的 json 尝试以下模型 类:

public class Example {
   int id;
   int page;
   List<Result> results = new ArrayList<Result>();
   int total_pages;
   int total_results;
}

public class Result {
   String id;
   String author;
   String content;
   String url;
}

如果您想将 JSON 转换为 POJO,请使用 jsonschema2pojo 执行此操作。

希望对您有所帮助!