XmlMapper seems to ignore custom serializer
See original GitHub issueI tried to add custom serializer to my XmlMapper for XML serialization:
JacksonXmlModule module = new JacksonXmlModule();
module.addSerializer(Item.class, new ItemSerializer());
XmlMapper xml = new XmlMapper(module);
However, it seems like XmlMapper ignore my serializer and serialize code on its own.
I tried this same serializer with ObjectMapper for JSON serialization:
SimpleModule module = new SimpleModule("MyModule", new Version(1,0,0,null,null,null);
module.addSerializer(Item.class, new ItemSerializer());
ObjectMapper json = new ObjectMapper();
json.registerModule(module);
It works fine for JSON.
Issue Analytics
- State:
- Created 11 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Jackson xml ignore empty Objects when serializing
XmlMapper xmlMapper = new XmlMapper(); xmlMapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);. I hope one of these helps, ten months late.
Read more >Jackson Ignore Properties on Marshalling
This tutorial will show how to ignore certain fields when serializing an object to JSON using Jackson 2.x.
Read more >Solving the XML Problem with Jackson
The XmlMapper is able to serialize an entire Java bean into a document that is currently being produced, allowing Jackson to integrate and ......
Read more >FasterXML/jackson-databind - Gitter
XmlMapper will create DeserializationContext to use (either itself or by ... Here is my custom serializer, i'm trying to implement this functionality, ...
Read more >Solving the XML Problem with Jackson
Jackson is a popular library for handling JSON in Java ... The XmlMapper is able to serialize an entire Java bean into a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@felixWackernagel There is unit test (
TestSerializerCustom.java
) that checks:so I would need more information on how your case differs.
But for issue tracking purposes, could you open a new issue? It is likely that underlying cause is different, and it is easier to create release notes when fixes are not spread across multiple releases (that is, fix for this problem was in 2.0.7; fix for remaining issue would go in 2.5.2)
@kbansod I commented on #41 already, asking for reproduction. This will be needed for fix.