Re: [Simple-support] How "not" to serialize nulls
Brought to you by:
niallg
|
From: Kevin J. <kjo...@in...> - 2008-04-22 14:06:03
|
thanks - i tried that, but didn't seem to work - it still inserts the given field's element, just with an empty value. -kevin On Apr 21, 2008, at 11:35 PM, Benoît Pointet wrote: > according to the tutorial > > (http://simple.sourceforge.net/download/stream/doc/tutorial/tutorial.php#optional > ) > > try setting the element as optional, i.e. > >> class foo { >> @Element(required=false) >> private String bar; >> } > > > b. > > On 22 avr. 08, at 07:48, Kevin Johnson wrote: > >> Hi, >> >> When serializing an object that has a null data member, the resulting >> xml has an empty element in it. Is there a way to avoid this? >> >> For example: >> >> class foo { >> @Element >> private String bar; >> } >> >> >> if "bar" has a value of "2", the xml will look like this: >> >> <foo> >> <bar>2</bar> >> </foo> >> >> but if "bar" has a value of NULL, the xml will look like this: >> >> <foo> >> <bar></bar> >> </foo> >> >> Where I would prefer: >> >> <foo> >> </foo> >> >> Is this possible? >> >> thanks, >> >> -kevin >> >> ------------------------------------------------------------------------- >> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference >> Don't miss this year's exciting event. There's still time to save >> $100. >> Use priority code J8TL2D2. >> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone >> _______________________________________________ >> Simple-support mailing list >> Sim...@li... >> https://lists.sourceforge.net/lists/listinfo/simple-support > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference > Don't miss this year's exciting event. There's still time to save > $100. > Use priority code J8TL2D2. > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone > _______________________________________________ > Simple-support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simple-support |