Как заставить JAXB сохранять нули при получении JSON-строки, содержащей нулевое или "" значение.
String:{"id":null, "fname": "John", "region":""}
returns Object:
Person {
Integer id = 0
String fname = "John"
Region regions = 0 }
Я бы хотел, чтобы он возвращал null вместо 0
Вот что у меня есть на данный момент:
@Provider
public class JAXBContextResolver implements ContextResolver<JAXBContext> {
private JAXBContext context;
private Class<?>[] types = {Person.class};
public JAXBContextResolver() throws Exception {
this.context = new JSONJAXBContext(JSONConfiguration.natural().build(), types);
}
public JAXBContext getContext(Class<?> objectType) {
for (Class<?> c : types) {
if (c.equals(objectType)) {
return context;
}
}
return null;
}
}
Person.class аннотирован @XmlRootElement
Я пробовал искать в аннотациях Jackson, но безуспешно.