I am reading multiple differing json files from server which needs to be re-used again. Some of the json files are using the same tree structure.
To accomplish this task is this the best method –
Define an interface which has getter/setter methods from below json and then an implementing class which creates a new object based on json. Is creating an interface for this task overkill ?
{
"type":"test",
"children":[
{
"id":testId,
"type":"laptop",
"price":"500",
}
]
}
I don’t think this would be overkill, if you are creating different objects and you are going to need the same attributes, then I would say this is the right approach.
You can also consider using a factory pattern.