In my application, JAXB output generates:
this.marshalOut(jaxb_Object, fileOutputStream);
this is a method call for spring Marshallers matching XML objects that generate XML files. Now I also like to generate JSON files after this line. Anyone have the idea of generating JSON output using JAXB input.
I found this sample code online:
ObjectMapper mapper = new ObjectMapper();
AnnotationIntrospector introspector = new JacksonAnnotationIntrospector();
// make deserializer use JAXB annotations (only)
mapper.getDeserializationConfig().setAnnotationIntrospector(introspector);
// make serializer use JAXB annotations (only)
mapper.getSerializationConfig().setAnnotationIntrospector(introspector);
mapper.writeValue( outputStream, jaxb_object);
setAnnotationIntrospector out of date, is there any other way to solve this problem?
source
share