I have an program that already transform POJOs to xml via JAXB and this is done by adding a the elements to a list in this form
List<JAXBElement<?>> elementsToTransform = new ArrayList<JAXBElement<?>>();
In other method I just transform and populate the elementsToTransform as xml, the firm of this method is something like this
private List<JAXBElement<?>> transform(Student student)
Now I need to add a way to transform to Json via Gson and I want to abstract both declaration and method in order to support both formats but the implementation is pretty hardcoded to xml and I need to fit this solution as the way it is build with xml because this depends on other functionality that I do not want to modify so I would know if there is a way I can support both formats and which will be the better choice for this problem
At the end I would like to have something like this in the elementsToTransform list
JAXBElement(0)
JAXBElement(1)
JAXBElement(2)
String(3)(this will be Json)
Aucun commentaire:
Enregistrer un commentaire