Receiving an XML response, there are two main solutions decoding xml to a DTO object. Why should one prefer JAXB over jackson, or the other way around?
JAXB:
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(xmlString));
unmarshaller.unmarshal(reader, DtoObject.class);
Jackson:
mapper = new ObjectMapper() / new XmlMapper();
mapper.readValue(xmlString, DtoObjectc.class);
In my opinion, I will use JAXB, the following reason.
However I am not saying that which is good or bad. Again it is a choice to the developer to use.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With