Re: [Simple-support] How "not" to serialize nulls
Brought to you by:
niallg
|
From: Kevin J. <kjo...@in...> - 2008-04-23 04:20:17
|
I ran some more tests and sure enough it is working as designed. Must have been "developer fatigue" messing with my brain. Apologies for the confusion. thanks, -kevin On Apr 22, 2008, at 11:37 AM, Niall Gallagher wrote: > Hi > > Is the value an empty string? If it is then it will > come out with the elements. If this still does not > work then send me code that shows this, perhaps in the > form of a unit test. I find it unlikely that this is > an bug in the framework as this is very well tested. > > Niall > > --- Kevin Johnson <kjo...@in...> wrote: > >> 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 >> >> >> > ------------------------------------------------------------------------- >> 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 >> > > > > > ____________________________________________________________________________________ > Be a better friend, newshound, and > know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ |