Serialize and deserialize object to and from text

E

Edmond wong

Hi,

I am looking for a text encoder and text decoder for object
serialization and deserialization. Any one have work on such a tool
before and can share the source code?

I have the encoder working using recursion and reflection, but I don't
have a clue on the way to use recursion and reflection to read the text
back to object. In fact, I have been trying to build the decoder and
have been stucked on the case where the object contain a collection of
objects.

The encoder I build have the following text output:

{book:Book={{name:java.lang.String="Hitchhiker
Guide"}{author:Author={{name:java.lang.String="Edmond
Wong"}{email:java.lang.String="(e-mail address removed)"}{address:java.lang.String="123
Olive
Ave"}}}{price:double=49.99}{chapters:java.util.Vector={{chapter:Chapter={{no:int=1}{name:java.lang.String="Act
I"}}}{chapter:Chapter={{no:int=2}{name:java.lang.String="Act
II"}}}{chapter:Chapter={{no:int=3}{name:java.lang.String="Act III"}}}}}}}


Thanks,

Edmond
 
W

Wendy S

Edmond wong said:
I am looking for a text encoder and text decoder for object serialization
and deserialization. Any one have work on such a tool before and can
share the source code?

Serialization means binary data, doesn't it? I suppose you could base-64
encode the bytes, that would be text...

Is this homework?? I guess I'm just questioning inventing yet another
proprietary text format that you have to maintain code for.

But to answer the question, if I had to dump an object to text knowing that
I would need to reconstitute it later, I would use XML and the following
libraries from Jakarta:
http://jakarta.apache.org/commons/betwixt/ Object to XML
http://jakarta.apache.org/commons/digester/ XML to Object
 
E

Edmond wong

Wendy said:
Serialization means binary data, doesn't it? I suppose you could base-64
encode the bytes, that would be text...

Is this homework?? I guess I'm just questioning inventing yet another
proprietary text format that you have to maintain code for.

But to answer the question, if I had to dump an object to text knowing that
I would need to reconstitute it later, I would use XML and the following
libraries from Jakarta:
http://jakarta.apache.org/commons/betwixt/ Object to XML
http://jakarta.apache.org/commons/digester/ XML to Object

I am more looking for an text encoder and decoder. I have the encoder
working using reflection and recursion.

I probably failed to convince my colleage who is a C++ programmer and
the project lead that xml is the best choice to log message, and to
regenerate the java object from log for simulation purpose. Anyway, I
will try again to convince the lead until I figure out the trick to
finish the decoder.

Thanks,

Edmond
 

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

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top