last day (14 days later) » 

7:00 AM
0
Q: Parsing Nested Json Object with Retrofit

Swapnil DeyI'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 excepti...

 
you have to create seperate model for entities.. Here is useful answer which may help you alot.
 
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
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.
 
Can you post your error log ? and try printing Profile String as well.. What will happen ? Is your profile string null ?
 
Profile string is not null. It's printing in the logcat but at the same time its crashing the App with nullpointer exception
 
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..
 
7:00 AM
I pass the entities list to my Recyclerview Adapter and I'm trying to print it there.
It did print the value
But app still crashed stating null point
 
It is hard to find out the problem without seeing codes. In which line it's showing nullpointer exception. Edit your question post your whole error stacktrace, I will watch
 
Okay. I'm trying to debug. Let me post it in a better way
 
ok notify me after posting
I am leaving for short break and I will catch up after 1/2 hours. Stay cool !!!
 
7:16 AM
did you check if your json response is valid?
I think problem is with json.
 
 
1 hour later…
8:30 AM
@ZeeshanShabbir It's valid json. I've checked
@SwapnilDey did you solve it ?
 
 
5 hours later…
1:36 PM
@Zee
@ZeeshanShabbir I think you're right. The problem is with the json, it is inconsistent. Though the JSON structure is correct so it didn't catch my attention.
 

last day (14 days later) »