What is the best way to deal with the following problem:
I have a mobile iPhone and Android application that sends and receives data to a Webservice using JSON. My application needs to work offline, with users being able to stay weeks without internet, and when they can connect, the server receives the data and synchronizes.
However, if there is a change in Webservice in the meantime, the expected JSON may change (customer requirement). My solution was to do a treatment layer in the Webservice that receives the JSON version of the App and converts the data to the format it expects. The problem is that each version requiring such a change requires that the treatment layer be updated for each of the previous versions.
I wonder if there is a better method to handle this case or if I'm already using the best method.
Thank you.
EDIT:
Being more specific in the treatment layer, I'm treating it like this:
My problem is in step 3, because I thought about using interfaces, however, an older version might not instantiate models that are mandatory in newer versions (for example when a new functionality is implemented).
For now I'm following case by case, updating each AppDecoder to handle new features, but I see that these classes will grow indefinitely.
Is there a better way to handle this case?