2016-03-14 57 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