Well that didn't come out right =). I put the same comment into Wink-299 where the formatting is correct. -- Jesse -----Jesse A Ramos/Austin/i...@ibmus wrote: -----
To: [email protected] From: Jesse A Ramos/Austin/i...@ibmus Date: 09/23/2010 12:53PM Subject: Re: Making Jackson the default JSON provider After fiddling with things a bit I found that taking all the defaults for the JacksonJaxbJsonProvider results in null properties being marshaled into the resulting JSON for JAXB Objects. I think we should suppress these from being written. Looking at our unit tests, I see we do the following: <code> JacksonJaxbJsonProvider jacksonProvider = new JacksonJaxbJsonProvider(); jacksonProvider.configure(Feature.WRITE_NULL_PROPERTIES, Boolean.FALSE); return new Object[] {jacksonProvider}; </code> However, Feature.WRITE_NULL_PROPERTIES is deprecated. It looks like using this code instead, we achieve the same thing: <code> JacksonJaxbJsonProvider jacksonProvider = new JacksonJaxbJsonProvider(); ObjectMapper mapper = new ObjectMapper(); mapper.getSerializationConfig().setSerializationInclusion(Inclusion.NON_NULL); AnnotationIntrospector pair = new AnnotationIntrospector.Pair(new JaxbAnnotationIntrospector(), new JacksonAnnotationIntrospector()); mapper.getDeserializationConfig().setAnnotationIntrospector(pair); mapper.getSerializationConfig().setAnnotationIntrospector(pair); jacksonProvider.setMapper(mapper); </code> I'm planning to check in a WinkJacksonJaxbJsonProvider that uses this configuration. Thoughts? -- Jesse -----Mike Rheinheimer <[email protected]> wrote: ----- To: [email protected] From: Mike Rheinheimer <[email protected]> Date: 09/21/2010 02:48PM Subject: Re: Making Jackson the default JSON provider Yeah, Jesse's right. JacksonJsonProvider and JacksonJaxbJsonProvider both support Jackson annotations. The JacksonJaxbJsonProvider adds support for JAXB annotations. I love that my prior incorrectness will live on forever in infamy! :) Thanks. mike On Tue, Sep 21, 2010 at 2:39 PM, Jesse A Ramos <[email protected]> wrote: > +1 > > The doc seems to indicate that JacksonJaxbJsonProvider has the same > functionality as JacksonJsonProvider except that it adds the JAXB support. > JacksonJaxbJsonProvider extends JacksonJsonProvider. > - Jesse > > -----Mike Rheinheimer <[email protected]> wrote: ----- > > To: [email protected] > From: Mike Rheinheimer <[email protected]> > Date: 09/21/2010 02:20PM > Subject: Re: Making Jackson the default JSON provider > > Yup, Jason, you make a good point. If an app developer wishes to use > Jackson-specific annotations, they must use JacksonJaxbJsonProvider, so > let's be sure to make that the Wink default, not JacksonJsonProvider, if we > intend to allow for that. If we don't, then Wink app developers would > have > to declare JacksonJaxbJsonProvider themselves in their Application subclass > getClasses method. > > I'm ok with making JacksonJaxbJsonProvider the Wink default, thereby > allowing Jackson-specific annotations out-of-the-box. Any other > opinions? > > mike > > > On Tue, Sep 21, 2010 at 1:45 PM, Jason Dillon <[email protected]> wrote: > > > The short answer is... I don't know ;-) It does look like the > latest 1.6 > > JacksonJaxbJsonProvider should work fine as-is. I've just updated > my app to > > configure a JacksonJaxbJsonProvider.class via getClasses() and it seems > > happy enough. > > > > I do use the jaxb+json provider here because I am using some jackson > > specific annotations, specifically @JsonTypeInfo, to enrich the json data > > slightly in some cases. This helps bridge the gap between xml & > json wrt > > lists of heterogeneous data. Xml worked due to the additional > namespaces > > introduced, json didn't w/o a little bit of help from jackson. > > > > --jason > > > > > > On Sep 21, 2010, at 9:44 AM, Jesse A Ramos wrote: > > > > > Thanks Mike, > > > > > > Your question was going to be my next one =). Didn't want to convolute > > the original query. > > > > > > I took a look at the Jackson javadoc but didn't find anything that said > > what the defaults were. It seemed to me, based on the functionality > of > > JacksonJaxbJsonProvider and JacksonJsonProvider, that the defaults were > > likely the same but I wasn't sure. > > > > > > - Jesse > > > > > > -----Mike Rheinheimer <[email protected]> wrote: ----- > > > > > > To: [email protected] > > > From: Mike Rheinheimer <[email protected]> > > > Date: 09/21/2010 11:30AM > > > Subject: Re: Making Jackson the default JSON provider > > > > > > +1 to making Jackson the default JSON provider. Most other JAX-RS > impls > > use > > > it as their default AFAIK, Jackson is a quite active community, and the > > main > > > dev lead over there (Tatu Saloranta) was the main developer on Woodstox > > STAX > > > parser. It's a very high quality project. > > > > > > Looking at WINK-299, I'm not sure what Jason has that Jackson does not > > > already provide by default. The JacksonJsonProvider, which is the > base > > > class for JacksonJaxbJsonProvider, already has all of what's shown in > 299 > > as > > > its defaults: > > > > > > > > > http://svn.jackson.codehaus.org/browse/jackson/trunk/src/jaxrs/java/org/codehaus/jackson/jaxrs/JacksonJsonProvider.java?r=HEAD > > > (see locateMapper method, line 565) > > > > > > Jason, is the explicit mapper instantiation still required, per your > code > > > snippet in WINK-299? > > > > > > mike > > > > > > > > > On Tue, Sep 21, 2010 at 10:59 AM, Jesse A Ramos <[email protected]> > > wrote: > > > > > >> In reference to WINK-299: > > https://issues.apache.org/jira/browse/WINK-299 > > >> > > >> Hi, > > >> > > >> As mentioned in WINK-299, Jackson seems to be the best available JSON > > >> provider. It would be good to make this default for WINK. > I don't mind > > >> making the change but wanted to get some opinions on a couple of > things. > > >> > > >> 1) Does everyone agree that Jackson should be the default JSON > provider? > > >> 2) If so, what default configuration settings should we use? > > >> > > >> For question 2, Jason provided a code snippet for what he is using in > > >> WINK-299. It likes good to me as a default configuration. > If others > > >> agree I can use that, otherwise let me know what other configuration > > >> settings you would like to use. > > >> > > >> Thanks, > > >> Jesse > > > > > > > > >
