I'm writing an android app that requires binding a JSON object into a domain entity with the keys from the JSON as instance variables. Since there are several domain entities, each with different instance variables that the JSON needs to bind to in the app, i'd like to write a method such as ths following:
- Loop through all the instance variables from the domain
- if a key exists in the JSON with the name of the instance variable, take the value for this key from the JSON and set the Domain's instance variable with this key name equal to this value.
The reason i'm interested in the doing the binding from the class to the JSON is because if the JSON changes for some reason, I don't want it to break the app when the instance variable doesn't exist in the app's domain for a specific JSON key.
Thanks in advance for any help!