I am looking for help in reading/writing of JSON string in my DB in a backward compatible way. The JSON names and objects are in case class FeatureList.
Old format:
"featureRequired":"Yes"
New format:
"featureRequired": {"thisfeatureRequired" :"Yes", "featureDetails": "Some text"}
case class FeatureList (
field1 : type,
.
.
.
featureRequired: Boolean //this is field22
)
The Issue : The legacy code reads featureRequired as a string. Then converts to boolean for decision making. For my new requirement, featureRequired is an object of {thisfeatureRequired, featureDetails}
We use scala play library for json manipulation.
The question : For my requirement, how do I READ the new format, which is backward compatible with the old one? Will custom formatter help? Can someone give an example please.