serialization

Maintain object references through Serialize/Deserialize

When serializing, I would like to serialize an object only once, then any references to that object should be serialized as a reference to the object. This is because, when I later deserialize the objects, I would like to maintain those references. To illustrate my goal, the code below should output "After Serialization: true". class Pr...

Is there a way for reading/writing serializable objects to a RandomAccesFile?

How can I read/write serializable object instances to a RandomAccessFile in Java? I want to be able to do this the same way you do it in c++ through structs. In java only ObjectInputStreams/ObjectOutputStreamscan can read/Write objects. I am amazed Java does not have something already implemented. ...

Best serialization library for .net with ability to deserialize inheritance correctly

I need a serialization library for .net with better features than the default xml serializer. The problem is that it is not polymorphic - say you have class B : A { }, and have serialized an type B, you should be able to call A myBaseType = Deserialize(xml) on it and be returned an instance of type B in the myBaseType variable. I have...

What generic collections in C# are IXmlSerializable?

Are any of the .NET generic collections marked as IXmlSerializable? I've tried List<T> and Collection<T> but neither work out of the box. Before I roll my own collection<T>, list<T>, or dictionary<T> class, I thought I'd check to see whether Microsoft had included something that does this already. It seems like basic functionality. EDI...

Boost Serialization using polymorphic archives

I am working on a client-server application that uses boost::serialization library for it's serialization needs. I need to serialize and deserialize polymorphic objects that does not seem to work. The documentation does say that it is supported but none of the related examples demonstrate what I'm trying to do here. So, I am not very ...

c# stream received all data?

I'm using C#.Net and the Socket class from the System.Net.Sockets namespace. I'm using the asynchronous receive methods. I understand this can be more easily done with something like a web service; this question is borne out of my curiosity rather than a practical need. My question is: assume the client is sending some binary-seriali...

Remove xml namespaces from WCF restful response

I am using WCF to return a plain old XML (POX) document to the caller. I am using the XML Serializer formatter to turn the objects into XML. In the returned document I have some extraneous xml namespace references (that weren't there in the ASMX version) for the XML Schema and instance. I have seen various arguments on the web that ...

trying to copy struct members to byte array in c

Hi, I am attempting to copy the members of a struct containing a mixture of ints, char's and arrays of chars into a byte array to send to a serial line. So far I have // struct msg_on_send // { // char descriptor_msg[5]; // int address; // char space; // char cmdmsg[5]; // char CR; // char LF; // }; /...

How to serialize an Exception object in C#?

Hello all, I am trying to serialize an Exception object in C#. However, it appears that it is impossible since the Exception class is not marked as Serializable. Is there a way to work around that? UPDATE: If something goes wrong during the execution of the application, I want to be informed with the exception that occurred. My first r...

Serialize in memory object with C#

I've got a program that picks up some code from script files and compiles it. And It works fine. The problem is: in the scripts I declare a couple of classes and I want to serialize them. Obviously the C# serializer (xml and binary) doesn't like to serialize and the de-serialize object defined in a in-memory assembly. I prefer to don't...

Serialize Oracle row to XML

I want to create a stored procedure that takes the name of a table and a row_id and can serialize it to an xml string. The table may contain clobs and blobs. Can I do this in PL/SQL, or do I have to use Java? The main objective for this is to have a table with all updates and deletes on some tables, keeping the X latest versions, or X...

Serialize Class containing Dictionary member

Expanding upon my earlier problem, I've decided to (de)serialize my ConfigFile class which worked great. I now want to store an associative array of drive letters to map (key is the drive letter, value is the network path) and have tried using Dictionary, HybridDictionary, and Hashtable for this but I always get the following error when ...

Serialising state that is NOT exposed as a property

I have a problem with serialisation. The class in question represents a network packet and has an associated byte array for payload, which may be null. I exposed this using GetData and SetData methods in line with Microsoft Framework Design Guidelines recommendations, because in order to prevent bizarre crosstalk, reading and writing th...

What's the best serialization method for objects in memcached?

My Python application currently uses the python-memcached API to set and get objects in memcached. This API uses Python's native pickle module to serialize and de-serialize Python objects. This API makes it simple and fast to store nested Python lists, dictionaries and tuples in memcached, and reading these objects back into the applic...

How do you access the symbol table in Ruby?

Is there a way to access everything in the symbol table in Ruby? I want to be able to serialize or otherwise save the current state of a run of a program. To do this, it seems I need to be able to iterate over all the variables in scope. ...

How should I deserialize this string data?

My application receives strings that represent objects. I have to parse the strings to get the property values for the object I'm creating. Each object will have to know the specifics about how many attributes there are, what each attribute means, etc. However, I want to avoid having each class know about how to parse the string. I'd...

What type of OO data structure should I use for this string data?

Let's say my program is always passed a string of characters that represents a data table in Wiki syntax. Something like: {||Client:||ABC|-|Contact:||Joe Smith|-|Current revision:||1.0||} I don't want each one of my specific Wiki table objects (e.g., ClientContactTable, CustomerOrderTable, etc.) to know how to parse out | and - and...

XmlSerializer and decorated classes (C#)

I leveraging the XmlSerializer to convert to/from XML. Here is an example class: [XmlRootAttribute("myClass")] public class MyClass { private string someField; [XmlElement("someField")] public string SomeField { get { return someField; } set { someField = value; } ...

serialize a bitmap within a custom object

I've got a valuetype object that I'm trying to serialize (via a BinaryFormatter) but within this object there are 3 Bitmaps which, when serializing the object throw a "general gdi+ exception" (no seriously, that's the exception). It's imperative that these bitmaps get serialized into the file (as opposed to just storing their relative ...

Binary Deserialization with different assembly version

I have a project which uses BinaryFormatter to serialize a collection of structs with string and bool? datatypes. The serialization/deserialization works fine, however if I were to change the assembly which does the work it fails to deserialize because of the header in the binary file indicating that it requires Assembly x instead of As...