The Serializer pattern lets you efficiently stream objects into data structures of your choice as well as create objects from such data structures. The Serializer pattern can be used whenever objects are written to or read from flat files, relational database tables, network transport buffers, etc.
Dirk Riehle, Wolf Siberski, Dirk Bäumer, Daniel Megert and Heinz Züllighoven. "Serializer." In Pattern Languages of Program Design 3. Edited by Robert Martin, Dirk Riehle, and Frank Buschmann. Reading, Massachusetts: Addison-Wesley, 1998. Chapter 17, page 293-312.
Erratum, p. 305. In void ASCIIStreamWriter::writeObject(...) change "if (!wasHandled->contains(object))" to "if (!wasHandled->contains(object) && !toHandle->contains(object))".
An earlier version appeared as: Dirk Riehle, Wolf Siberski, Dirk Bäumer, Daniel Megert and Heinz Züllighoven. "The Atomizer--Efficiently Streaming Object Structures." PLoP '96, conference proceedings. Washington University Department of Computer Science, Technical Report WUCS-97-07, 1997. Paper 2.7, 14 pages.
The paper is available as a PDF file. Please note that the final published article is a copy-edited version of this pdf file and therefore may differ in minor details from the version provided here.
The C++ sample code from the pattern is available as serializer.zip. No warranties, use at your own risk.
If you need a real-life example, please take a look at the JValue framework at www.jvalue.org. You might want to choose JValue v0.2, which shows a clean implementation of the Serializer pattern in Java, and ignore later versions that add more complexity.