2016-03-14 55 views
-1

我是新改装的。我需要为下面的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} 

回答

0

试试下面的模型类为您的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'S转换为上述使用jsonschema2pojo做到这一点。

希望这有助于!

+0

感谢@普拉特,感谢它 – Rogerto

+0

如果这个答案解决了你的问题,那么请接受这个答案。 – Harry