conditional serialization skip empty attributes

20 views
Skip to first unread message

Bruno

unread,
Feb 11, 2012, 3:06:47 PM2/11/12
to FxWorks
Hi!

Is it possible to skip certain objects when serializing?

for example, in my VO I have several attributes that dont get
populated and i would like to omit them on the serialization, like
empty arrays or null objects.

Many thanks in advance!

bruno

Alexutz

unread,
Feb 13, 2012, 5:06:33 AM2/13/12
to FxWorks
Looking through the code it seems that FlexXb already does that. if
you have null properties it will not serialize them. Do you not have
the same behavior?

Bruno Fenzl

unread,
Feb 14, 2012, 5:04:31 AM2/14/12
to fle...@googlegroups.com
Hi Alex!

Thanks for your answer. the node that gets serialized is an Array. If the array does not have any children, they are not written but parent itself is (the enclosing array) following is an example:

<imageFormats> node with contents:

<field section="section1" inputType="Image" tag="image" templateName="background" displayName="Image" contentType="Text" required="true">
              <imageFormats>
                <imageFormat name="article" width="748" height="374"/>
                <imageFormat name="grid" width="198" height="148"/>
                <imageFormat name="favorite" width="148" height="75"/>
              </imageFormats>
            </field>

<imageFormats> node with no contents (shouldnt exist)

<field section="section1" inputType="TextField" tag="location" templateName="venue" displayName="Location" contentType="Text" required="true">
              <imageFormats/>
            </field>

I´m still learning the library, but couldn´t find the error.

Thanks!!


--
You received this message because you are subscribed to the Google Groups "FxWorks" group.
To post to this group, send email to fle...@googlegroups.com.
To unsubscribe from this group, send email to flexxb+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/flexxb?hl=en.


Alexutz

unread,
Feb 14, 2012, 5:11:45 AM2/14/12
to FxWorks
Oh, ok, I see. Yes, empty arrays are still serialized. A quick fix
would be to set that array field to null.
> >http://groups.google.com/group/flexxb?hl=en.- Hide quoted text -
>
> - Show quoted text -

Bruno Fenzl

unread,
Feb 14, 2012, 5:16:28 AM2/14/12
to fle...@googlegroups.com
Ok, many thanks!!
Reply all
Reply to author
Forward
0 new messages