{"id":13406,"date":"2017-08-22T12:25:03","date_gmt":"2017-08-22T17:25:03","guid":{"rendered":"https:\/\/stackify.com\/?p=13406"},"modified":"2023-03-18T11:29:54","modified_gmt":"2023-03-18T11:29:54","slug":"java-xml-jackson","status":"publish","type":"post","link":"https:\/\/stackify.com\/java-xml-jackson\/","title":{"rendered":"Solving the XML Problem with Jackson"},"content":{"rendered":"<h3><b>Introduction<\/b><\/h3>\n<p>Jackson is a popular library for handling JSON in Java applications, quickly becoming the de-facto standard in the ecosystem. Starting with version 2, it has also introduced a mature <a href=\"https:\/\/github.com\/FasterXML\/jackson-dataformat-xml\">XML implementation<\/a> alongside its established JSON support.<\/p>\n<h3><b>Adding Jackson XML to the Project<\/b><\/h3>\n<p>Adding the Jackson XML module to the project only needs a single dependency &#8211; the Jackson XML module itself:<\/p>\n<pre class=\"prettyprint\">&lt;dependency&gt;\n    &lt;groupId&gt;com.fasterxml.jackson.dataformat&lt;\/groupId&gt;\n    &lt;artifactId&gt;jackson-dataformat-xml&lt;\/artifactId&gt;\n    &lt;version&gt;2.9.0&lt;\/version&gt;\n&lt;\/dependency&gt;<\/pre>\n<p>And in Gradle:<\/p>\n<pre class=\"prettyprint\">compile \"com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.9.0\"<\/pre>\n<p>This will automatically pull in all of the other Jackson dependencies that are needed:<\/p>\n<ul>\n<li>Jackson Core<\/li>\n<li>Jackson Annotations<\/li>\n<li>Jackson Databind<\/li>\n<li>Jackson Module JAXB Annotations<\/li>\n<li><a href=\"https:\/\/github.com\/FasterXML\/woodstox\" target=\"_blank\" rel=\"noopener noreferrer\">Woodstox StAX Implementation<\/a><\/li>\n<\/ul>\n<p>Note that the Woodstox StAX library can be excluded and replaced with any other valid implementation of the StAX API.<\/p>\n<h3><b>Configuring the Jackson XML Module<\/b><\/h3>\n<p>Jackson is typically used by means of an <i>ObjectMapper<\/i> instance. <b>In order to work with XML, we&#8217;ll instead use the <\/b><b><i>XmlMapper<\/i><\/b><b> class.<\/b> This is a direct extension of <i>ObjectMapper<\/i> and can be used as a replacement, with the exact same API we&#8217;re already used to.<\/p>\n<p>The absolute simplest way of working with this is to just use the default configuration:<\/p>\n<pre class=\"prettyprint\">ObjectMapper objectMapper = new XmlMapper();<\/pre>\n<p>However, if we need additional configuration, we can instead construct the Jackson Module manually and set it up as necessary:<\/p>\n<pre class=\"prettyprint\">JacksonXmlModule xmlModule = new JacksonXmlModule();\nxmlModule.setDefaultUseWrapper(false);\nObjectMapper objectMapper = new XmlMapper(module);<\/pre>\n<p>As of version 2.9.0, the only configuration options for the XML Module are:<\/p>\n<ul>\n<li><i>setDefaultUseWrapper<\/i> &#8211; defines whether or not to use a wrapper for non-annotated List properties by default<\/li>\n<li><i>setXMLTextElementName<\/i> &#8211; defines the virtual name to use when processing character data sections &#8211; when not binding to Java beans<\/li>\n<\/ul>\n<p>Due to the fact that the <i>XmlMapper<\/i> extends the standard <i>ObjectMapper<\/i>, we can essentially use all of the standard Jackson <i>ObjectMapper<\/i> configuration settings and APISs.<\/p>\n<p>For example, we can configure it to produce indented output as follows:<\/p>\n<pre class=\"prettyprint\">objectMapper.enable(SerializationFeature.INDENT_OUTPUT);<\/pre>\n<p>Note that some of these settings might not work with some XML implementations. For example, older versions of Jackson XML depended on <em>Stax2Writer<\/em>, which didn&#8217;t support writing raw characters to the stream. This means that it doesn&#8217;t support writing the raw newlines and indentations needed for the <i>INDENT_OUTPUT<\/i> feature to work.<\/p>\n<h3><b>Object Serialization<\/b><\/h3>\n<p>Jackson is best known for its ability to serialize POJOs into JSON and back, by means of standard conventions and &#8211; where necessary &#8211; special annotations to give clues to the Jackson library.<\/p>\n<p>As already mentioned, the <i>XmlMapper<\/i> object directly replaced <i>ObjectMapper<\/i>, only it works in terms of XML instead of JSON. <b>This means that the API is exactly the same, and it can be used as a direct replacement<\/b>.<\/p>\n<h4>Writing XML<\/h4>\n<p><b>Writing XML is done using the various <\/b><b><i>writeValue<\/i><\/b><b> methods that Jackson exposes<\/b>. For example, marshalling some object to XML is done simply by using the <i>writeValueAsString<\/i> API:<\/p>\n<pre class=\"prettyprint\">String xml = objectMapper.writeValueAsString(input);<\/pre>\n<p>The standard versions of this all exist and work as expected:<\/p>\n<ul>\n<li>Writing to a String<\/li>\n<li>Writing to a Byte Array<\/li>\n<li>Writing to a <i>java.io.OutputStream<\/i> &#8211; e.g. for streaming over a network connection<\/li>\n<li>Writing to a <i>java.io.Writer<\/i><\/li>\n<li>Writing to a <i>java.io.File<\/i><\/li>\n<\/ul>\n<h4>Reading XML<\/h4>\n<p>As we just explored, we the library handles writing to XML quite well.<\/p>\n<p><b>We can also read XML, using the various <\/b><b><i>readValue<\/i><\/b><b> APIs that are part of provided by the&nbsp;<\/b><i><b>ObjectMapper<\/b><\/i>.<\/p>\n<p>For example, reading some XML from an <em>InputStream<\/em> into a Java Bean:<\/p>\n<pre class=\"prettyprint\">MyBean bean = objectMapper.readValue(inputStream, MyBean.class);<\/pre>\n<p>Again, the standard versions of this all exist, and work as expected:<\/p>\n<ul>\n<li>Reading from a String<\/li>\n<li>Reading from a Byte Array<\/li>\n<li>Reading from a <i>java.io.InputStream<\/i> &#8211; e.g. for streaming over a network connection<\/li>\n<li>Reading from a <i>java.io.Reader<\/i><\/li>\n<li>Reading from a <i>java.io.File<\/i><\/li>\n<\/ul>\n<h3><b>Jackson Annotations for Serialization<\/b><\/h3>\n<p><b>The Jackson XML module supports the full range of annotations that Jackson provides for annotating our POJOs<\/b>.<\/p>\n<p>This means that we can have one single set of beans, with one set of annotations and,&nbsp;depending on the <i>ObjectMapper<\/i> instance, we select whether we get XML or JSON. That&#8217;s a huge benefit when it comes to structuring our code, as we no longer have to worry about translating between different beans that represent essentially the same data just to get different serialization formats.<\/p>\n<p>For example, given the following bean:<\/p>\n<pre class=\"prettyprint\">@JsonPropertyOrder({\"age\", \"id\", \"name\"})\npublic class Person {\n    @JsonProperty(\"_id\")\n    private String id;\n\n    private String name;\n\n    private int age;\n\n    @JsonIgnore\n    private String note;\n}<\/pre>\n<p>will produce this JSON:<\/p>\n<pre class=\"prettyprint\">{\n    \"age\":4,\n    \"_id\":\"12345\",\n    \"name\":\"George\"\n}<\/pre>\n<p>And this XML:<\/p>\n<pre class=\"prettyprint\">&lt;Person&gt;\n    &lt;age&gt;4&lt;\/age&gt;\n    &lt;_id&gt;12345&lt;\/_id&gt;\n    &lt;name&gt;George&lt;\/name&gt;\n&lt;\/Person&gt;<\/pre>\n<h3><strong>Additional Jackson Annotations for XML<\/strong><\/h3>\n<p><b>The Jackson XML module adds some additional support for XML specific features.&nbsp;<\/b>These annotations allow us to control the XML namespace and local name for elements, including the root element, whether a field is rendered in an element or as plain text, whether the content of an element is rendered in a CData wrapper, and whether a collection should use a wrapper element or not.<\/p>\n<h4><em>@JacksonXmlProperty<\/em><\/h4>\n<p><em>@JacksonXmlProperty<\/em>&nbsp;can be applied to any field in a bean to control the details of the element that is being rendered. This annotation allows us to determine the namespace, the local name, and whether the field is serialized as an Element or an Attribute. For example, the following bean:<\/p>\n<p>For example, the following bean:<\/p>\n<pre class=\"prettyprint\">public class Person {\n    @JacksonXmlProperty(\n      isAttribute = true, namespace = \"urn:stackify:jacksonxml\", localName = \"_id\")\n    private String id;\n\n    @JacksonXmlProperty(namespace = \"urn:stackify:jackson\")\n    private String name;\n\n    private String note;\n}<\/pre>\n<p>This generates the following XML output:<\/p>\n<pre class=\"prettyprint\">&lt;Person xmlns:wstxns1=\"urn:stackify:jacksonxml\" \n        wstxns1:_id=\"12345\"&gt;\n    &lt;wstxns2:name xmlns:wstxns2=\"urn:stackify:jackson\"&gt;Graham&lt;\/wstxns2:name&gt;\n    &lt;note&gt;Hello&lt;\/note&gt;\n&lt;\/Person&gt;<\/pre>\n<h4><em>@JacksonXmlRootElement<\/em><\/h4>\n<p>The&nbsp;<em>@JacksonXmlRootElement<\/em> has a similar role to the&nbsp;<em>@JacksonXmlProperty<\/em> but for the root element of the entire document. This can only adjust the Namespace and Local name &#8211; since the root element can never be serialized as an attribute.<\/p>\n<p>For example, let&#8217;s look at this Java POJO:<\/p>\n<pre class=\"prettyprint\">@JacksonXmlRootElement(namespace = \"urn:stackify:jacksonxml\", localName = \"PersonData\")\npublic class Person {\n    private String id;\n\n    private String name;\n\n    private String note;\n}<\/pre>\n<p>When serialized, this will result in the following XML:<\/p>\n<pre class=\"prettyprint\">&lt;PersonData xmlns=\"urn:stackify:jacksonxml\"&gt;\n    &lt;id xmlns=\"\"&gt;12345&lt;\/id&gt;\n    &lt;name xmlns=\"\"&gt;Graham&lt;\/name&gt;\n    &lt;note xmlns=\"\"&gt;Hello&lt;\/note&gt;\n&lt;\/PersonData&gt;<\/pre>\n<h4><em>@JacksonXmlText<\/em><\/h4>\n<p>Next, let&#8217;s have a look at the&nbsp;<em>@JacksonXmlText<\/em>&nbsp;annotation.<\/p>\n<p>Simply put, this indicates that an element should be rendered as plain text without another element containing it.<\/p>\n<p>For example, the following POJO:<\/p>\n<pre class=\"prettyprint\">public class Person {\n    private String id;\n\n    private String name;\n\n    @JacksonXmlText\n    private String note;\n}<\/pre>\n<p>Will produce this simple XML output:<\/p>\n<pre class=\"prettyprint\">&lt;Person&gt;\n    &lt;id&gt;12345&lt;\/id&gt;\n    &lt;name&gt;Graham&lt;\/name&gt;\n    Hello\n&lt;\/Person&gt;<\/pre>\n<p>Naturally, you do have to be careful using this annotation and make sure you&#8217;re still generating valid XML.<\/p>\n<h4><em>@JacksonXmlCData<\/em><\/h4>\n<p>The&nbsp;<em>@JacksonXmlCData<\/em> annotation indicates that a CData wrapper should be placed around the content of the element. This can be used in conjunction with the&nbsp;<em>@JacksonXmlText<\/em> if desired to produce a CData wrapper without an element tag.<\/p>\n<p>Let&#8217;s have a look at a POJO using this annotation:<\/p>\n<pre class=\"prettyprint\">public class Person {\n    private String id;\n\n    @JacksonXmlCData\n    private String name;\n\n    @JacksonXmlText\n    @JacksonXmlCData\n    private String note;\n}<\/pre>\n<p>This will result in the following XML:<\/p>\n<pre class=\"prettyprint\">&lt;Person&gt;\n    &lt;id&gt;12345&lt;\/id&gt;\n    &lt;name&gt;&lt;![CDATA[Graham]]&gt;&lt;\/name&gt;\n    &lt;![CDATA[Hello]]&gt;\n&lt;\/Person&gt;<\/pre>\n<h4><em>JacksonXmlElementWrapper<\/em><\/h4>\n<p>The&nbsp;<em>@JacksonXmlElementWrapper<\/em> annotation is used to override the default setting from&nbsp;<em><i>setDefaultUseWrapper<\/i><\/em> &#8211; as seen above. This can ensure that a collection either does or does not use a wrapper element, and can control what the wrapper element uses for namespace and local name.<\/p>\n<p>When using wrapper elements, we get <strong>an additional element added which contains all of the elements from the collection<\/strong>, and when wrapper elements are not used then the individual collection elements are written directly inline:<\/p>\n<pre class=\"prettyprint\">class Wrapper {\n    @JacksonXmlElementWrapper(localName = \"list\")\n    private List names;\n}<\/pre>\n<p>This will produce the following XML:<\/p>\n<pre class=\"prettyprint\">&lt;Wrapper&gt;\n    &lt;list&gt;\n        &lt;names&gt;John&lt;\/names&gt;\n        &lt;names&gt;Paul&lt;\/names&gt;\n        &lt;names&gt;George&lt;\/names&gt;\n        &lt;names&gt;Ringo&lt;\/names&gt;\n    &lt;\/list&gt;\n&lt;\/Wrapper&gt;<\/pre>\n<p>Whereas, if the <i>JacksonXmlElementWrapper<\/i> is replaced with:<\/p>\n<pre class=\"prettyprint\">@JacksonXmlElementWrapper(useWrapping = false)<\/pre>\n<p>Then the XML produced won&#8217;t contain the <em>list<\/em> element:<\/p>\n<pre class=\"prettyprint\">&lt;Wrapper&gt;\n    &lt;names&gt;John&lt;\/names&gt;\n    &lt;names&gt;Paul&lt;\/names&gt;\n    &lt;names&gt;George&lt;\/names&gt;\n    &lt;names&gt;Ringo&lt;\/names&gt;\n&lt;\/Wrapper&gt;<\/pre>\n<h3><strong>Supporting JAXB Annotations<\/strong><\/h3>\n<p>The Jackson XML module also has the ability to support the standard JAXB annotations on our beans &#8211; instead of needing the Jackson specific ones. This can be useful if we want to use Jackson for the actual XML Serialization but don&#8217;t want to depend on it at compile time.<\/p>\n<p>This can also be used to allow JAXB to generate our bean definitions from an XML Schema and have Jackson process them.<\/p>\n<p>This functionality is an additional module that needs to be added in for it to work. It doesn&#8217;t work out of the box like the Jackson annotations do. In order to configure this &#8211; we need to add the <i>JaxbAnnotationModule<\/i> to our&nbsp;<i>ObjectMapper<\/i> as follows:<\/p>\n<pre class=\"prettyprint\">objectMapper.registerModule(new JaxbAnnotationModule());<\/pre>\n<p>We can now write or generate a Java bean with JAXB annotations and simply process it with this <i>XmlMapper<\/i>.<\/p>\n<p>For example, the following POJO:<\/p>\n<pre class=\"prettyprint\">@XmlRootElement(name = \"employee\")\n@XmlAccessorType(XmlAccessType.FIELD)\npublic class EmployeeBean {\n    @XmlAttribute(name = \"_id\")\n    @XmlID\n    private String id;\n\n    @XmlElement\n    private String name;\n\n    @XmlElement\n    private String type;\n}<\/pre>\n<p>Will produce the following XML when marshalled:<\/p>\n<pre class=\"prettyprint\">&lt;employee _id=\"12345\"&gt;\n    &lt;name&gt;Graham&lt;\/name&gt;\n    &lt;type&gt;Developer&lt;\/type&gt;\n&lt;\/employee&gt;<\/pre>\n<h3><b>Partial Reading and Writing<\/b><\/h3>\n<p>Jackson also has the powerful ability to actually <strong>jump into the middle of an existing XML file<\/strong> and either marshall or unmarshall XML to and from that file.<\/p>\n<p>The functionality makes good use of the standard <i>XMLStreamWriter<\/i> class, and naturally of <i>XMLStreamReader<\/i> as well. This cool functionality gives us a lot of flexibility to work with existing XML documents and integrate with these cleanly and easily.<\/p>\n<h4>Generating XML<\/h4>\n<p>The <i>XmlMapper<\/i> is able to serialize an entire Java bean into a document that is currently being produced, allowing Jackson to integrate and construct the document along with other external actors. This also gives some ability to support constructs that Jackson cannot handle natively &#8211; for example, the XML Prolog.<\/p>\n<p>In order to do this, the <i>XmlMapper<\/i> needs to be called to write values to the <i>XMLStreamWriter<\/i> object &#8211; the same as if we were writing to any other <i>Writer<\/i>:<\/p>\n<pre class=\"prettyprint\">StringWriter stringWriter = new StringWriter();\nXMLOutputFactory xmlOutputFactory = XMLOutputFactory.newFactory();\nXMLStreamWriter sw = xmlOutputFactory.createXMLStreamWriter(stringWriter);\n\nXmlMapper mapper = new XmlMapper();\n\nsw.writeStartDocument();\nsw.writeStartElement(\"root\");\n\nmapper.writeValue(sw, employeeBean);\nsw.writeComment(\"Some insightful commentary here\");\nsw.writeEndElement();\nsw.writeEndDocument();<\/pre>\n<p>This will produce the following XML:<\/p>\n<pre class=\"prettyprint\">&lt;?xml version='1.0' encoding='UTF-8'?&gt;\n&lt;root&gt;\n    &lt;employee _id=\"12345\"&gt;\n        &lt;name&gt;Graham&lt;\/name&gt;\n        &lt;type&gt;Developer&lt;\/type&gt;\n    &lt;\/employee&gt;\n    &lt;!--Some insightful commentary here--&gt;\n&lt;\/root&gt;<\/pre>\n<p>Here, the XML Prolog, <i>root<\/i> element, and the comment &#8211; are not produced by Jackson XML, but everything inside the <i>EmployeeBean<\/i> element is.<\/p>\n<h4>Consuming XML<\/h4>\n<p>The opposite of this is also possible &#8211; deserializing a Java bean from the middle of an <i>XMLStreamReader<\/i>.<\/p>\n<p>This can be especially useful if we only care to have Java bean representations for data in the middle of a larger object &#8211; for example, if we are parsing an Atom wrapper around the data we are interested in.<\/p>\n<p>In order to do this, the <i>XmlMapper<\/i> needs to be called to read values from the <i>XMLStreamReader<\/i> object &#8211; the same as if we were reading from any other <i>Reader<\/i>.<\/p>\n<p>Let&#8217;s have a look at a simple example. The following Java code will consume the XML generated above into an <i>EmployeeBeen<\/i> instance:<\/p>\n<pre class=\"prettyprint\">XMLInputFactory f = XMLInputFactory.newFactory();\nXMLStreamReader sr = f.createXMLStreamReader(new FileInputStream(inputFile));\n\nXmlMapper mapper = new XmlMapper();\nsr.next(); \/\/ to point to &lt;root&gt;\nsr.next(); \/\/ to point to root-element under root\nEmployeeBeen employee = mapper.readValue(sr, EmployeeBeen.class);\nsr.close();<\/pre>\n<h3><b>Limitations of the Jackson XML Module<\/b><\/h3>\n<p>The XML module in Jackson is by no means designed to be an exact replacement for JAXB. There are certain constructs that will work subtly differently between JAXB and Jackson, and there is no guarantee that Jackson will produce identical XML to JAXB.<\/p>\n<p>Note that, unlike with JSON, the outermost object must be a bean type &#8211; it can not be a primitive or wrapper type, an enumeration, or a collection. This is a direct result of how XML works &#8211; there&#8217;s no way in XML to represent such a top-level value.<\/p>\n<p>By default, Jackson will always use a wrapper element for collections, which is also <strong>different to how JAXB works<\/strong>. This is the major way that the XML produced by Jackson is not compatible with the XML produced by JAXB. Of course, the behavior can be configured, using the <i>JacksonXmlElementWrapper<\/i> annotation for one field or the <i>setDefaultUseWrapper<\/i> configuration setting on the <i>XmlMapper<\/i> globally.<\/p>\n<p>Jackson also has <strong>no support for working with specific XML Schemas<\/strong>. It&#8217;s designed for writing Java Beans first, rather than generating the Java code from pre-existing schemas. Note that this can be solved to an extent by using the JAXB annotation support and generating the beans using the standard <i>xjc<\/i> tool.<\/p>\n<p>Equally, it has no support for some of the more advanced XML tools &#8211; such as XPath or XSLT. If we need this level of support then we should instead use a more full-featured XML solution.<\/p>\n<h3><strong>Usage on Android<\/strong><\/h3>\n<p>In the mobile space, Jackson XML works perfectly well on Android. However, the StAX API is not included in the Android JVM, so it needs to instead be bundled manually.<\/p>\n<p>If we&#8217;re using the Woodstox XML library that Jackson XML depends on by default &#8211; there&#8217;s nothing extra to be done. If, however, we&#8217;re using an alternative library &#8211; then we might need to add that dependency manually:<\/p>\n<pre class=\"prettyprint\">&lt;dependency&gt;\n    &lt;groupId&gt;javax.xml.stream&lt;\/groupId&gt;\n    &lt;artifactId&gt;stax-api&lt;\/artifactId&gt;\n    &lt;version&gt;1.0-2&lt;\/version&gt;\n&lt;\/dependency&lt;\/span&gt;\n<\/pre>\n<p>And for Gradle:<\/p>\n<pre class=\"prettyprint\">compile \"javax.xml.stream:stax-api:jar:1.0-2\"<\/pre>\n<h3><b>Summary<\/b><\/h3>\n<p>If you&#8217;re looking for a mature, flexible way of supporting and working with both JSON and XML for the same data, the Jackson XML module is a fantastic library to leverage. It&#8217;s not only a solid way to go on its own, but it also has the added benefit of being able to mostly reuse the same configuration for both XML as well as JSON.<\/p>\n<p>Typically, this has to be handled using two different libraries with entirely separate configurations.<\/p>\n<p>Finally, beyond flexibility and ease-of-use, the Jackson team has <a href=\"https:\/\/github.com\/FasterXML\/jackson-docs\/wiki\/Presentation:-Jackson-Performance\">historically<\/a> placed a strong emphasis <a href=\"https:\/\/github.com\/fabienrenaud\/java-json-benchmark\">on performance<\/a>. And given that <strong>marshalling and unmarshalling of data is a large part of most web applications<\/strong>, choosing the right library to handle all of that work is critical. That, plus a performance monitoring tool such as <a href=\"https:\/\/stackify.com\/retrace\/\">Retrace<\/a> will allow you to get the most out of your app.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Jackson is a popular library for handling JSON in Java applications, quickly becoming the de-facto standard in the ecosystem. Starting with version 2, it has also introduced a mature XML implementation alongside its established JSON support. Adding Jackson XML to the Project Adding the Jackson XML module to the project only needs a single [&hellip;]<\/p>\n","protected":false},"author":15,"featured_media":38253,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[7],"tags":[40],"class_list":["post-13406","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-developers","tag-java"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.6 (Yoast SEO v25.6) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Solving the XML Problem with Jackson - Stackify<\/title>\n<meta name=\"description\" content=\"Looking for a mature, flexible way of working with both JSON and XML for the same data? Read how the Jackson XML module is a fantastic library to leverage.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/stackify.com\/java-xml-jackson\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Solving the XML Problem with Jackson - Stackify\" \/>\n<meta property=\"og:description\" content=\"Looking for a mature, flexible way of working with both JSON and XML for the same data? Read how the Jackson XML module is a fantastic library to leverage.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/stackify.com\/java-xml-jackson\/\" \/>\n<meta property=\"og:site_name\" content=\"Stackify\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/Stackify\/\" \/>\n<meta property=\"article:published_time\" content=\"2017-08-22T17:25:03+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-03-18T11:29:54+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/stackify.com\/wp-content\/uploads\/2017\/08\/Solving-XML-Problem-with-Jackson-881x441-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"881\" \/>\n\t<meta property=\"og:image:height\" content=\"441\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Eugen Paraschiv\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@stackify\" \/>\n<meta name=\"twitter:site\" content=\"@stackify\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Eugen Paraschiv\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/stackify.com\/java-xml-jackson\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/stackify.com\/java-xml-jackson\/\"},\"author\":{\"name\":\"Eugen Paraschiv\",\"@id\":\"https:\/\/stackify.com\/#\/schema\/person\/e372b6a6f64edbedafad33027d518482\"},\"headline\":\"Solving the XML Problem with Jackson\",\"datePublished\":\"2017-08-22T17:25:03+00:00\",\"dateModified\":\"2023-03-18T11:29:54+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/stackify.com\/java-xml-jackson\/\"},\"wordCount\":2004,\"publisher\":{\"@id\":\"https:\/\/stackify.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/stackify.com\/java-xml-jackson\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/stackify.com\/wp-content\/uploads\/2017\/08\/Solving-XML-Problem-with-Jackson-881x441-1.jpg\",\"keywords\":[\"Java\"],\"articleSection\":[\"Developer Tips, Tricks &amp; Resources\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/stackify.com\/java-xml-jackson\/\",\"url\":\"https:\/\/stackify.com\/java-xml-jackson\/\",\"name\":\"Solving the XML Problem with Jackson - Stackify\",\"isPartOf\":{\"@id\":\"https:\/\/stackify.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/stackify.com\/java-xml-jackson\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/stackify.com\/java-xml-jackson\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/stackify.com\/wp-content\/uploads\/2017\/08\/Solving-XML-Problem-with-Jackson-881x441-1.jpg\",\"datePublished\":\"2017-08-22T17:25:03+00:00\",\"dateModified\":\"2023-03-18T11:29:54+00:00\",\"description\":\"Looking for a mature, flexible way of working with both JSON and XML for the same data? Read how the Jackson XML module is a fantastic library to leverage.\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/stackify.com\/java-xml-jackson\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/stackify.com\/java-xml-jackson\/#primaryimage\",\"url\":\"https:\/\/stackify.com\/wp-content\/uploads\/2017\/08\/Solving-XML-Problem-with-Jackson-881x441-1.jpg\",\"contentUrl\":\"https:\/\/stackify.com\/wp-content\/uploads\/2017\/08\/Solving-XML-Problem-with-Jackson-881x441-1.jpg\",\"width\":881,\"height\":441},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/stackify.com\/#website\",\"url\":\"https:\/\/stackify.com\/\",\"name\":\"Stackify\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/stackify.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/stackify.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/stackify.com\/#organization\",\"name\":\"Stackify\",\"url\":\"https:\/\/stackify.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/stackify.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/stackify.com\/wp-content\/uploads\/2024\/05\/logo-1.png\",\"contentUrl\":\"https:\/\/stackify.com\/wp-content\/uploads\/2024\/05\/logo-1.png\",\"width\":1377,\"height\":430,\"caption\":\"Stackify\"},\"image\":{\"@id\":\"https:\/\/stackify.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/Stackify\/\",\"https:\/\/x.com\/stackify\",\"https:\/\/www.instagram.com\/stackify\/\",\"https:\/\/www.linkedin.com\/company\/2596184\",\"https:\/\/www.youtube.com\/stackify\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/stackify.com\/#\/schema\/person\/e372b6a6f64edbedafad33027d518482\",\"name\":\"Eugen Paraschiv\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/stackify.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/0c0bb39bd24aea78b56c6516a3e7dcab?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/0c0bb39bd24aea78b56c6516a3e7dcab?s=96&d=mm&r=g\",\"caption\":\"Eugen Paraschiv\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Solving the XML Problem with Jackson - Stackify","description":"Looking for a mature, flexible way of working with both JSON and XML for the same data? Read how the Jackson XML module is a fantastic library to leverage.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/stackify.com\/java-xml-jackson\/","og_locale":"en_US","og_type":"article","og_title":"Solving the XML Problem with Jackson - Stackify","og_description":"Looking for a mature, flexible way of working with both JSON and XML for the same data? Read how the Jackson XML module is a fantastic library to leverage.","og_url":"https:\/\/stackify.com\/java-xml-jackson\/","og_site_name":"Stackify","article_publisher":"https:\/\/www.facebook.com\/Stackify\/","article_published_time":"2017-08-22T17:25:03+00:00","article_modified_time":"2023-03-18T11:29:54+00:00","og_image":[{"width":881,"height":441,"url":"https:\/\/stackify.com\/wp-content\/uploads\/2017\/08\/Solving-XML-Problem-with-Jackson-881x441-1.png","type":"image\/png"}],"author":"Eugen Paraschiv","twitter_card":"summary_large_image","twitter_creator":"@stackify","twitter_site":"@stackify","twitter_misc":{"Written by":"Eugen Paraschiv","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/stackify.com\/java-xml-jackson\/#article","isPartOf":{"@id":"https:\/\/stackify.com\/java-xml-jackson\/"},"author":{"name":"Eugen Paraschiv","@id":"https:\/\/stackify.com\/#\/schema\/person\/e372b6a6f64edbedafad33027d518482"},"headline":"Solving the XML Problem with Jackson","datePublished":"2017-08-22T17:25:03+00:00","dateModified":"2023-03-18T11:29:54+00:00","mainEntityOfPage":{"@id":"https:\/\/stackify.com\/java-xml-jackson\/"},"wordCount":2004,"publisher":{"@id":"https:\/\/stackify.com\/#organization"},"image":{"@id":"https:\/\/stackify.com\/java-xml-jackson\/#primaryimage"},"thumbnailUrl":"https:\/\/stackify.com\/wp-content\/uploads\/2017\/08\/Solving-XML-Problem-with-Jackson-881x441-1.jpg","keywords":["Java"],"articleSection":["Developer Tips, Tricks &amp; Resources"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/stackify.com\/java-xml-jackson\/","url":"https:\/\/stackify.com\/java-xml-jackson\/","name":"Solving the XML Problem with Jackson - Stackify","isPartOf":{"@id":"https:\/\/stackify.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/stackify.com\/java-xml-jackson\/#primaryimage"},"image":{"@id":"https:\/\/stackify.com\/java-xml-jackson\/#primaryimage"},"thumbnailUrl":"https:\/\/stackify.com\/wp-content\/uploads\/2017\/08\/Solving-XML-Problem-with-Jackson-881x441-1.jpg","datePublished":"2017-08-22T17:25:03+00:00","dateModified":"2023-03-18T11:29:54+00:00","description":"Looking for a mature, flexible way of working with both JSON and XML for the same data? Read how the Jackson XML module is a fantastic library to leverage.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/stackify.com\/java-xml-jackson\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/stackify.com\/java-xml-jackson\/#primaryimage","url":"https:\/\/stackify.com\/wp-content\/uploads\/2017\/08\/Solving-XML-Problem-with-Jackson-881x441-1.jpg","contentUrl":"https:\/\/stackify.com\/wp-content\/uploads\/2017\/08\/Solving-XML-Problem-with-Jackson-881x441-1.jpg","width":881,"height":441},{"@type":"WebSite","@id":"https:\/\/stackify.com\/#website","url":"https:\/\/stackify.com\/","name":"Stackify","description":"","publisher":{"@id":"https:\/\/stackify.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/stackify.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/stackify.com\/#organization","name":"Stackify","url":"https:\/\/stackify.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/stackify.com\/#\/schema\/logo\/image\/","url":"https:\/\/stackify.com\/wp-content\/uploads\/2024\/05\/logo-1.png","contentUrl":"https:\/\/stackify.com\/wp-content\/uploads\/2024\/05\/logo-1.png","width":1377,"height":430,"caption":"Stackify"},"image":{"@id":"https:\/\/stackify.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/Stackify\/","https:\/\/x.com\/stackify","https:\/\/www.instagram.com\/stackify\/","https:\/\/www.linkedin.com\/company\/2596184","https:\/\/www.youtube.com\/stackify"]},{"@type":"Person","@id":"https:\/\/stackify.com\/#\/schema\/person\/e372b6a6f64edbedafad33027d518482","name":"Eugen Paraschiv","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/stackify.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/0c0bb39bd24aea78b56c6516a3e7dcab?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/0c0bb39bd24aea78b56c6516a3e7dcab?s=96&d=mm&r=g","caption":"Eugen Paraschiv"}}]}},"_links":{"self":[{"href":"https:\/\/stackify.com\/wp-json\/wp\/v2\/posts\/13406"}],"collection":[{"href":"https:\/\/stackify.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/stackify.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/stackify.com\/wp-json\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/stackify.com\/wp-json\/wp\/v2\/comments?post=13406"}],"version-history":[{"count":1,"href":"https:\/\/stackify.com\/wp-json\/wp\/v2\/posts\/13406\/revisions"}],"predecessor-version":[{"id":38254,"href":"https:\/\/stackify.com\/wp-json\/wp\/v2\/posts\/13406\/revisions\/38254"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/stackify.com\/wp-json\/wp\/v2\/media\/38253"}],"wp:attachment":[{"href":"https:\/\/stackify.com\/wp-json\/wp\/v2\/media?parent=13406"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/stackify.com\/wp-json\/wp\/v2\/categories?post=13406"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/stackify.com\/wp-json\/wp\/v2\/tags?post=13406"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}