Extension for Jackson JSON processor that adds support for serializing POJOs as XML (and deserializing from XML) as an alternative to JSON
574
stars
222
forks
source link
Support Encoding option when writing XML #636
Closed
4n0nym1ty closed 10 months ago
We used spring boot v3.2.1 , create bean object to convert json to xml and
jackson-dataformat-xml v2.16.1 added as dependency
@Bean public MappingJackson2XmlHttpMessageConverter converter(Jackson2ObjectMapperBuilder builder) { XmlMapper xmlMapper = builder.createXmlMapper(true).build(); xmlMapper.configure(ToXmlGenerator.Feature.WRITE_XML_DECLARATION, true); xmlMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); return new MappingJackson2XmlHttpMessageConverter(xmlMapper); }
we are able to convert json to xml but we are missing encoding xml version [<?xml version="1.0" encoding="UTF-8"?>]