接收XML响应,有两种主要解决方案将 xml 解码为 DTO 对象。为什么一个人应该JAXB更喜欢jackson,或者相反?
贾克斯:
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);
慕娘9325324
大话西游666
叮当猫咪
相关分类