Serializing Object Model

D

Dave T

From a web service I'm serializing out an object model. Is there a way to
only include those elements of the object model which actually contain data?
 
P

PJ6

Dave T said:
From a web service I'm serializing out an object model. Is there a way to
only include those elements of the object model which actually contain
data?

It can be done, you will need a to write custom serializer for for that.
I've written one before and don't remember it being too difficult.

If you do that, though, you may have trouble deserializaing the result to
any wsdl-generated classes you may be using on the consumer side. To get
around that you could break down the object in question into a hierarchy of
classes; in that case you could probably eliminate your need for a custom
serializer to crop away empty fields altogether if you're dealing with a
broad yet deep tree of data.

All that being said: if your reason for doing this is size, I wouldn't
bother; 99% of the time doing this would be poor design, and if you turn on
(or manually implement) compression you'll find that XML data shrinks by a
factor of 30 because of its high tokenization.

Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top