Parsing JSON into Object Model with Retrofit in Android -
a few days ago started using retrofit instead of okhttp in order comunicate api. goes perfect have doubt , didn't found nothing clear it.
if have json response api this
{ "event": { "status": "4", "participants": "5.455" }, "more_data": "string_data", "even_more_data": 0 } that means should have pojo structure this?
public class event { @serializedname("event") public eventdata data; @serializedname("more_data") public string moredata; @serializedname("even_more_data") public int evenmoredata; } public class eventdata { @serializedname("status") public string eventstatus; @serializedname("participants") public string numberofparticipants; } is there anyway store information in single pojo?
thanks
@joseph82, it's not idea use inner classes. there real possibility memory leaks if not careful , if don't know doing. thus, recommend stick 2 classes approach when using retrofit (personal opinion).
here link stackoverflow discussion on topic. check "garbage collection , non-static inner classes" section
Comments
Post a Comment