Search code examples
httpkotlinretrofitresponse

How to avoid unsafe calls and create a better response models structure?


I'm trying to parse Spacex api request Click here to see json structure. I've created a pojo models structure using Android studio plugin. Now it looks like Click here to see I'm using this code for getting a necessary fields. enter image description here
As you can see it's not so good. Could you please give me a tip how to avoid such code in my application and create a better response structure using Base classes and abstraction? The response structure has lots of nested classes.


Solution

  • If you are developing android application, Use DataBinding and send detail.rocket.secondStage.payload[0] as model to it