FasterXML / jackson-dataformat-xml

Extension for Jackson JSON processor that adds support for serializing POJOs as XML (and deserializing from XML) as an alternative to JSON
Apache License 2.0
561 stars 221 forks source link

Support Encoding option when writing XML #636

Closed 4n0nym1ty closed 5 months ago

4n0nym1ty commented 5 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"?>]

pjfanning commented 5 months ago

duplicate of #315