0

I'm using Retrofit to parse a JSON returned by the API in this link using POJO Model Classes as mentioned in Retrofit Documentation I use asynchronous method to successfully get the tags inside "entities". However, when I try to get the "profile" tag from the "Media", I get a Null pointer exception and the App crashes.

I tried printing the "Profile" data from Media tag to the LogCat, the App crashes but I can see the URL string printed in LogCat along with Null Pointer Exception for the same method.

This is confusing as my method returns the mapped Data from API but, still shows Null Pointer Exception.

  • you have to create seperate model for entities.. Here is useful [answer](http://stackoverflow.com/questions/23070298/get-nested-json-object-with-gson-using-retrofit) which may help you alot. – Shree Krishna Jan 31 '16 at 06:38
  • Yes. I have separate classes for entities. I'm facing the problem with retrieving data from the Media tag inside an individual "entity". Can you help with that? I'm able to read the profile tag inside media as well but, the app is unable to print it. It crashes with null pointer exception – Swapnil Dey Jan 31 '16 at 06:41
  • I have seen that answer but, it doesn't solve my problem. I needn't use a Custom Deserializer as my API response is a very standard JSON. – Swapnil Dey Jan 31 '16 at 06:43
  • Can you post your error log ? and try printing Profile String as well.. What will happen ? Is your profile string null ? – Shree Krishna Jan 31 '16 at 06:55
  • Profile string is not null. It's printing in the logcat but at the same time its crashing the App with nullpointer exception – Swapnil Dey Jan 31 '16 at 06:56
  • Where did you print that ? Is that in onSuccess or onResponse method of retrofit ? OR outside that method by passing ? Try debugging if you ran into onFailure method then post your retrofit error too.. – Shree Krishna Jan 31 '16 at 06:59
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/102123/discussion-between-swapnil-dey-and-shree-krishna). – Swapnil Dey Jan 31 '16 at 07:00

0 Answers0