REQUIRED CONNECTED LIBRARIES: Jackson Core, Bind and Annotation 2.6.1
Two classes have the same fields, but they don't have a common superclass. Example, First and Second classes.
Implement the convertOneToAnother method, which should return an instance of the resultClassObject class.
Using JSON to convert from one class to another
- 14
Locked
Comments (1)
- Popular
- New
- Old
You must be signed in to leave a comment
Justin Smith
30 September 2022, 14:14
I thought I had this one solved, but no. Checked the solution.
My feeling is that this task is sort of a bandaid on bad project design. If the two classes have the same variables and are meant to be swapped this way, then they probably should be one class, or one of them should inherit the other, or both of them should inherit a parent class, or they should both implement the same interface. Once you have a solution that's concatenating escape-sequenced characters in the way the official solution does here, I feel like there has to be a better way to do this. Converting one Java object into another Java object should not require passing the object through JSON.
0