Re: [Simple-support] How "not" to serialize nulls
Brought to you by:
niallg
|
From: Benoît P. <ben...@un...> - 2008-04-22 06:36:15
|
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 |