Jackson Glossary: XmlMapper

Role

This is a special subtype of ObjectMapper: it is configured with handlers (instances of JsonFactory, other handlers) that can read and write XML, instead of JSON.

This feature was added after Jackson 1.7, as "mini-JAXB" project, Jackson extension.

Usage

Used similar to regular ObjectMappers, like: Serializer factory is used via ObjectMapper, and factory in use can be changed with:

   1   XmlMapper mapper = new XmlMapper();
   2   MyBean bean = new MyBean();
   3   String xml = mapper.writeValueAsString(bean);
   4   // we get something like "<MyBean><property>value</property>....</MyBean>"
   5   MyBean beanFromXml = mapper.readValue(xml, MyBean.class);


Back to Jackson Term Glossary


CategoryJackson

XmlMapper (last edited 2011-03-12 06:33:00 by TatuSaloranta)

Copyright ©2009 FasterXML, LLC