I need to send a json response. I use the jackson library to convert the class to json. I have a core java class to which I need to add some more fields to create my json response. I came with two ideas.
- To extend the core java class.
- To have an another class with the core class object as constructor.
Concerns over two methods are:
- I have a core layer which returns core java object from database. I need to call a method to return my extended class object. In core layer, I have to create instance of the extended class and return
- I can easily achieve json response with this but for every object, there will be a wrapper kind of object created.
Kindly guide me to have a design pattern for this