1

I am using jackson 2.4 + JaxbAnnotationModule

In some cases, I would like to apply an XMLJavaTypeAdapter to the jaxb object, for example the below:

@XmlJavaTypeAdapter(IntegerAdapter.class)
@XmlSchemaType(name = "int")
protected Integer favoriteNumber;

This is working well for the deserialization process. However, it seems that if I serialize the object containing this field to json, the result becomes a string instead of an integer

"favoriteNumber": "21"

Is there a way to serialize this value to an integer in json with jackson/jaxb while using an XmlJavaTypeAdapter?

indybee
  • 1,507
  • 13
  • 17
  • Can you post a complete runnable example that demonstrates the problem. I can reproduce the problem. It works fine for me _without_ using any adapters – Paul Samsotha Sep 28 '14 at 15:30
  • @peeskillet - it serializes to an integer for me too without the adapter. However, i would like to use the same field "favoriteNumber" for request and response, and when it is used for a request, I would like to use an adapter for additional processing. Is there a way to have the value serialized as integer while using the adapter? – indybee Sep 28 '14 at 18:45
  • did you tried this http://bethecoder.com/applications/tutorials/xml/jaxb/xml-adapter.html? – Ken de Guzman Sep 30 '14 at 03:23
  • I've experienced same problem here... Did you manage to find a solution? – Mateusz Stefaniak Nov 25 '21 at 20:48

0 Answers0