I am using Retrofit for networking in Android. I want to send some data to backend in one scenario but I want to send the same data albeit with a 1 key missing in another scenario. eg-
data: { "test" : "hello", "test2" :"hi"}
data: { "test" : "hello"}
The endpoint is the same. Only the data is different. I could do this by making different function calls and sending them different data but I thought of making a superclass and subclassing two POJO classes from it. Then depending upon the usecase I would just send the relevant subclass . But for that I would have to declare the uncommon data members in the subclass.
Will the Json parser
pick the relevant members from the subclasses
? Is this possible?