|
From: colin g. <cgs...@gm...> - 2010-09-21 21:51:02
|
Ok, yeah that is the difference. The jackson version that I'm using is 1.0.1 and that annotation isn't available. The @JsonWriteNullProperties(false) is and it works. Thanks for your help! On Tue, Sep 21, 2010 at 2:22 PM, Stephen Friedrich < ste...@fo...> wrote: > Hm, I am not using the resteasy Jackson provider from > resteasy-jackson-provider.jar, but the provider included in jackson itself. > > I am using all three jars jackson-core-asl-1.3.2,jar, > jackson-jaxrs-1.3.2.jar and Jackson-mapper-asl.1.3.2.jar. The @JsonSerialize > annotation is part of the Jackson mapper jar. > > > > -- Stephen > > > > > > *Stephen Friedrich* > > *FORTIS IT-Services GmbH*** > > Duvenstedter Damm 72 > D-22397 Hamburg > > T +49 (0)40 607699-22 > F +49 (0)40 607699-20 > M +49 (0)163 6767732 > E ste...@fo... > http://www.fortis-it.de > > Geschäftsführer: > Hubertus Bergmann, Winald Kasch > HRB 85134, Sitz der Gesellschaft: Hamburg > > > > *Von:* colin gray [mailto:cgs...@gm...] > *Gesendet:* Dienstag, 21. September 2010 21:07 > *An:* Stephen Friedrich > *Cc:* res...@li... > *Betreff:* Re: [Resteasy-developers] Removing Null Values from RESTEasy > JSON Response > > > > Thanks for the response Stephen! I'm unable to find the JsonSerialize > class. I'm using the 1.1.GA version of RESTEasy and including the > resteasy-jackson-provider jar. Is there an additional dependency needed? > > On Tue, Sep 21, 2010 at 11:56 AM, Stephen Friedrich < > ste...@fo...> wrote: > > @Provider > > public class ObjectMapperResolver implements ContextResolver<ObjectMapper> > { > > public ObjectMapperResolver() { > > } > > > > public ObjectMapper getContext(Class<?> type) { > > ObjectMapper mapper = new ObjectMapper(); > > > > > mapper.getSerializationConfig().setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL); > > > > return mapper; > > } > > } > > > > > > -- Stephen > > > > *Von:* colin gray [mailto:cgs...@gm...] > *Gesendet:* Dienstag, 21. September 2010 20:51 > *An:* res...@li... > *Betreff:* [Resteasy-developers] Removing Null Values from RESTEasy JSON > Response > > > > Hi, > > > > I switched from the Jettison to the Jackson provider for RESTEasy and now > null values in the JSON objects are appearing. Jettison seems to > automatically remove null property values from the response objects. I > switched to get around a bug with Jettison and would really like to go with > Jackson. Is there an annotation to suppress null property values in the > repsonse? > > > > Jackson Response: > > {"error":null,"responses":[{"group":[{"groupId":2400,"groupNumber":1,"groupName":"g2","devices":[{"userId":null,"messengerName":null,"esn":"0-81360","customerNum":null,"deviceType":null,"memberShipId":null,"authCode":null,"alertId":"DEFAULT","creditCardRequired":false,"selectedFeatures":null}],"addresses":[{"address":" > cg...@ya...","type":"smtp","label":null,"addressId":7648},{"address":"cg...@ya...","type":"smtp","label":"Colin<cg...@ya...%22,%22type%22:%22smtp%22,%22label%22:null,%22addressId%22:7648%7d,%7b%22address%22:%22...@ya...%22,%22type%22:%22smtp%22,%22label%22:%22Colin>Gray( > cg...@ya...)","addressId":7692},{"address":"te...@gm...","type":"smtp","label":null,"addressId":7645},{"address":"cgs...@ya...","type":"smtp","label":null,"addressId":6076},{"address":"cg7...@ya...","type":"smtp","label":null,"addressId":7682},{"address":"888...@ce...","type":"sms","label":"Colin<cg...@ya...)%22,%22addressId%22:7692%7d,%7b%22address%22:%22...@gm...%22,%22type%22:%22smtp%22,%22label%22:null,%22addressId%22:7645%7d,%7b%22address%22:%22c...@ya...%22,%22type%22:%22smtp%22,%22label%22:null,%22addressId%22:6076%7d,%7b%22address%22:%22c...@ya...%22,%22type%22:%22smtp%22,%22label%22:null,%22addressId%22:7682%7d,%7b%22address%22:%228...@ce...%22,%22type%22:%22sms%22,%22label%22:%22Colin>Gray( > 888...@ce...)","addressId":7690<888...@ce...)%22,%22addressId%22:7690> > }]}]}]} > > > > Jettison Response: > > {"response":{"groupsResponse":{"groups":{"group":{"groupId":2400,"groupName":"g2","groupNumber":1,"devices":{"deviceId":"0-81360"},"addresses":[{"addressId":7682,"type":"smtp","address":" > cg7...@ya..."},{"addressId":7648,"type":"smtp","address":"cg...@ya..."},{"addressId":7645,"type":"smtp","address":"te...@gm..."},{"addressId":7690,"type":"sms","address":"888...@ce...","label":"Colin<cg7...@ya...%22%7d,%7b%22addressId%22:7648,%22type%22:%22smtp%22,%22address%22:%22...@ya...%22%7d,%7b%22addressId%22:7645,%22type%22:%22smtp%22,%22address%22:%22...@gm...%22%7d,%7b%22addressId%22:7690,%22type%22:%22sms%22,%22address%22:%228...@ce...%22,%22label%22:%22Colin>Gray( > 888...@ce...)"},{"addressId":7692,"type":"smtp","address":"cg...@ya...","label":"Colin<888...@ce...)%22%7d,%7b%22addressId%22:7692,%22type%22:%22smtp%22,%22address%22:%22...@ya...%22,%22label%22:%22Colin>Gray( > cg...@ya...)"},{"addressId":6076,"type":"smtp","address":"cgs...@ya...<cg...@ya...)%22%7d,%7b%22addressId%22:6076,%22type%22:%22smtp%22,%22address%22:%22c...@ya...> > "}]}}}}} > > > > > > > -- > Colin Gray > > > > > -- > Colin Gray > -- Colin Gray |