serialization

Why can't I send my custom class through my webservice?

I have these classes: public abstract class CustomField { public String Id { get; set; } public String Name { get; set; } public String Description { get; set; } public FieldType Type { get; set; } public enum FieldType { String = 0, Integer = 1, Boolean = 2, List = 3 } } p...

XML Serialization of an Object Containing invalid chars

I'm serializing an object that contains HTML data in a String Property. Dim Formatter As New Xml.Serialization.XmlSerializer(GetType(MyObject)) Dim fs As New FileStream(FilePath, FileMode.Create) Formatter.Serialize(fs, Ob) fs.Close() But when I'm reading the XML back to the Object: Dim Formatter As New Xml.Serialization.XmlSerialize...

Can .NET XmlSerializer class deserialize InnerXml as a string?

I have a very specific deserialization need, see example below: say I have following class: [Serializable] public class Person { public string Name { get; set; } public string PersonXml { get; set; } } and following XML <Person> <Name>John</Name> <PersonXml><someXmlFragment>text</someXmlFragment></PersonXml> </Person> Wh...

How do I change and/or move a class that has been serialized?

I've got a class in my project and I want to move and rename that class to somewhere else in the project's namespace. I tried simply moving it, but then the program won't deserialize any settings saved under Properties.Settings.Default for that setting. Is there a way I can move it without losing all of the user's settings? ...

Serializing an object and storing it to a varbinary field in a DB

I can serialize an object to a file using: var writeStream = File.Open("l.osl", FileMode.Create); var bformatter = new BinaryFormatter(); bformatter.Serialize(writeStream, l); What I am trying to do is instead of writing it to a file, write it to a DB varbinary field. I assume that I have to change writeStream to something else, but w...

Java serialization: readObject() vs. readResolve()

The book Effective Java and other sources provide a pretty good explanation on how and when to use the readObject() method when working with serializable Java classes. The readResolve() method, on the other hand, remains a bit of a mystery. Basically all documents I found either mention only one of the two or mention both only individual...

How to serialize a UIView? (iphone)

Hi everyone, Is it possible to serialize a UIView object? If yes how can I do that? Thanks ...

deserialisation of multiple elements not working?

Dear friends, i have the following XSD: <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt; <xsd:element name="Persons"> <xsd:complexType> <xsd:sequence> <xsd:element name="PersonFullName"> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:pattern value="[A-Z0-9]{3,50}"/> </xsd:restriction> ...

How do I ignore event subscribers when serializing an object?

Note that I'm answering my own question since I think it might be useful to have the information on the site! FAQ: It's also perfectly fine to ask and answer your own question, but pretend you're on Jeopardy: phrase it in the form of a question. When the following class is serialized with a BinaryFormatter, any objects subscribin...

What could be the reason that my custom REST serializer is not working?

Both methods MyBehavior::CreateSerializer() are not called of some reason, but ReplaceBehavior() method is working. It is changing default behavior with my custom one. Do someone know where could be the problem? The point is to write custom REST WCF serializer that should generate non-XML text format result. public class MySerializ...

DataContractSerializer, KnownType and inheritance

I've read many articles about known types and i belive my example should work. But it doesn't. I'm getting the following exception on deserialization and don't understand why: Error in line 1 position 2. Expecting element 'A' from namespace 'http://schemas.datacontract.org/2004/07/ConsoleApplication2'.. Encountered 'Element' with name ...

Best practices for serializing objects to a custom string format for use in an output file

Hello! I was just about to implement an override of ToString() on a particular business class in order to produce an Excel-friendly format to write to an output file, which will be picked up later and processed. Here's what the data is supposed to look like: 5555555 "LASTN SR, FIRSTN" 5555555555 13956 STREET RD TOWNSVILLE MI 48890 25....

Inconsistent DataContractAttribute behavior

based on my understanding WCF's data contract model was opt-in vs the old opt-out approach of asmx web-services. you have to explicitly include all the fields and types that you require using DataContractAttribute and DataMemberAttribute. my experience however has been different. take a look at the following examples, ///CASE: 1 ///B...

Serialize form to JSON with jQuery

How do I serialize all elements of my form to a JSON object? I'd like to have some way of automatically building a JSON object from my form, without having to loop over each element. I do not want a string, as returned by $('#formid').serialize();, nor do I want the map returned by $('#formid').serializeArray(); ...

FileHelpers-like data import/export utility for binary data?

I use the excellent FileHelpers library when I work with text data. It allows me to very easily dump text fields from a file or in-memory string into a class that represents the data. In working with a big endian microcontroller-based system I need to read a serial data stream. In order to save space on the very limited microcontroller ...

Boost: How to deserialize inside a method?

I have a problem deserializing data serialized using Boost.Serialization. I want a method like this DataObject* Transmitter::read(). DataObject is the parent class of multiple classes that can be send using Transmitter::write(DataObject& data). What I have at the moment looks like this, but it doesn't work. DataObject* Transmitter::rea...

Looking for a fast, compact, streamable, multi-language, strongly typed serialization format

I'm currently using JSON (compressed via gzip) in my Java project, in which I need to store a large number of objects (hundreds of millions) on disk. I have one JSON object per line, and disallow linebreaks within the JSON object. This way I can stream the data off disk line-by-line without having to read the entire file at once. It t...

Book on .Net Serialization?

Hi All, Can anyone please recomend me a book on >net Serialization? ...

Custom java serialization of message

Hi, While writing a message on wire, I want to write down the number of bytes in the data followed by the data. Message format: {num of bytes in data}{data} I can do this by writing the data to a temporary byteArrayOutput stream and then obtaining the byte array size from it, writing the size followed by the byte array. This approac...

Appending to an ObjectOutputStream

Is it not possible to append to an ObjectOutputStream? I am trying to append to a list of objects. Following snippet is a function that is called whenever a job is finished. FileOutputStream fos = new FileOutputStream (preferences.getAppDataLocation() + "history" , true); ObjectOutputStream out = new ObjectOutputStream(fos);...