Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/209.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 改造模型对象_Android_Json_Retrofit2 - Fatal编程技术网

Android 改造模型对象

Android 改造模型对象,android,json,retrofit2,Android,Json,Retrofit2,我是新装修的。我需要为下面的JSON查询创建一个Parcelable模型对象,但似乎无法让它工作。我有点困惑,因为下面的JSON中有两个id属性。任何帮助都会很好 JSON查询 {"id":83542,"page":1,"results":[{"id":"51910979760ee320eb020fc2","author":"Andres Gomez","content":"Interesting film with an exceptional cast, fantastic perfo

我是新装修的。我需要为下面的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;
}
公共类示例{
int-id;
整版;
列表结果=新建ArrayList();
int总页数;
int-total_结果;
}
公开课成绩{
字符串id;
字符串作者;
字符串内容;
字符串url;
}
如果您想将JSON转换为上面提到的POJO,请使用


希望这有帮助

谢谢@pratt,非常感谢。如果这个答案解决了你的问题,那么请接受这个答案。