Hi all,
I have googled this issue to death with no joy, so am trying on here...
Here is the initial problem:
1. I am using JAXB to generate a Java object model from a provided XSD.
2. There are various integer fields in the schema. XML documents we receive
do not always conform to the schema. Specifically, the id field will
sometimes be sent empty. e.g. <userId/> - this is unmarshalled by JAXB as
the integer 0.
I have tried adding a custom binding attached to int fields which will
nullify any empty elements we receive. The unmarshaller is defined as:
public static Integer unmarshal(final String v) {
try {
return Integer.parseInt(v);
} catch (NumberFormatException e){
return null;
}
}
This works for unmarshalling the incoming XML. However the JSON marshaller
(usiing the JaxbAnnotationIntrospector) now marshalls the userId as a String.
i.e. {..., "userId": "87", ...} rather than {..., "userId": 87, ...} which it
should be.
Does anyone know either:
a) a better way of handling the bad input XML OR
b) a way of solving the marshalling issue.
Thanks in advance.
--
You received this message because you are subscribed to the Google Groups
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/d/optout.