【发布时间】:2019-11-25 07:09:27
【问题描述】:
收到XML 响应后,有两种主要解决方案将 xml 解码为 DTO 对象。为什么人们更喜欢JAXB 而不是jackson,或者相反?
JAXB:
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(xmlString));
unmarshaller.unmarshal(reader, DtoObject.class);
杰克逊:
mapper = new ObjectMapper() / new XmlMapper();
mapper.readValue(xmlString, DtoObjectc.class);
【问题讨论】: