When Geting Objects From A Json With Restlet How Can I Get Different Objects In Case The Json Chnges Its Structure
I have a Json with some hierarchy, that at some point can change in its structure. The key OnOff can either have an object or an array, it can have an array like this: 'OnOff': [
Solution 1:
You could call the Resource#toObject(representation, Target1.class|Target2.class) to try to convert to both classes.
But this isn't clear why you can simply rely on the second Capability class which can handle both single and multiple items. Maybe you don't control the server?
Another option is to add Jackson annotations, a base abstract Capability class and two subclasses https://github.com/FasterXML/jackson-annotations
Post a Comment for "When Geting Objects From A Json With Restlet How Can I Get Different Objects In Case The Json Chnges Its Structure"