users@jersey.java.net

[Jersey] Re: nil instead of null

From: nbaliga <nbaliga_at_cleartrial.com>
Date: Mon, 26 Sep 2011 07:14:48 -0700 (PDT)

I did try using the 1.9 SNAPSHOT in my efforts to incorporate a Jackson
provider in my Jersey project.

However, and I double checked this morning, the root unwrapping feature
doesn't work for me. I still get the Java name of the root variable instead
of the XmlRootElement name attribute value.

I think this is a side effect of the fact that Jackson seems to be ignoring
the JAXB annotations altogether, because the propOrder of the elements is
also being ignored.

Here are the options I'm configuring my ObjectMapper with:
      
      objectMapper = new ObjectMapper();

      objectMapper.configure( SerializationConfig.Feature.WRAP_ROOT_VALUE,
true );

      objectMapper.configure( SerializationConfig.Feature.INDENT_OUTPUT,
false );

      objectMapper.configure( SerializationConfig.Feature.USE_ANNOTATIONS,
true );

      objectMapper.configure(
JsonGenerator.Feature.WRITE_NUMBERS_AS_STRINGS, false );

      objectMapper.configure( DeserializationConfig.Feature.USE_ANNOTATIONS,
true );


      final AnnotationIntrospector introspector = new
JaxbAnnotationIntrospector();

      // make serializer use JAXB annotations (only)
      objectMapper.getSerializationConfig().withAnnotationIntrospector(
introspector );

      // make deserializer use JAXB annotations (only)
      objectMapper.getDeserializationConfig().withAnnotationIntrospector(
introspector );


I toggled the INDENT_OUTPUT option to ensure that Jersey is indeed using the
ObjectMapper instance that I am providing, and sure enough the output
changed according to what I set this feature to.

I am using Jersey 1.5 btw.



--
View this message in context: http://jersey.576304.n2.nabble.com/nil-instead-of-null-tp6821681p6832030.html
Sent from the Jersey mailing list archive at Nabble.com.