serialization

Java serialization problem

I have following code to serialize my data into a file: out = new ObjectOutputStream(new FileOutputStream(file)); out.writeObject(chunk); out.flush(); I read with the following: in = new ObjectInputStream(new FileInputStream(file)); Chunk chunk = (Chunk) in.readObject(); The weird thing is, when I read the data, all members are set...

Is it possible to exclude some members of a type from XmlSerializer serialization?

I have some public members I don't want to be serialized, was wondering if there is an attribute for it? ...

Unsafe generic cast when deserializing a Collection

public Configuration(Node node, File file) { HashMap<String, String> conf = (HashMap<String, String>) SerializationUtils.deserialize(new FileInputStream(file)); } I understand why this gives an unsafe cast warning, but what's the best/accepted way to do this safely? Is there any good way? ...

Strategy for Dealing with 64bit/32bit when transferring Binary data between Machines via TCP/IP

I've been working on a project where I need to transfer large volumes of Binary data some are Structs, enums, lists etc and some are pure binary data, I'm trying to develop a strategy for dealing with the issues when transferring the data between a 64bit compile and a 32bit compile. Presently I mark the assembly to just target 32bit to ...

C# serialize decimal to xml

Hi, I got a decimal property, like [XmlElementAttribute(DataType = "decimal")] decimal Price The problem is that I wanna force it to serialize always with precision of 2, but if the price is 10.50 it will be serialized to XML like <Price>10.5</Price>. Theres any way to force it (without creating a new property or changing the get of...

How to serialize attached properties

Hello everyone, I am writing .NET3.5, WPF application using Composite Application Library. Application is divided into several modules. In infrastructure module I have defined NetworkNode object. The Network module manages a collection of NetworkNodes and uses XmlSerializer to store/load this collection. So far everythings works. But...

Multidimensional array serialization

function source_of (array, up_to_dimension) { // Your implementation } source_of([1, [2, [3]]], 0) == '[1, ?]' source_of([1, [2, [3]]], 1) == '[1, [2, ?]]' source_of([1, [2, [3]]], 2) == '[1, [2, [3]]]' source_of([532, 94, [13, [41, 0]], [], 49], 0) == '[532, 94, ?, ?, 49]' I have very huge multidimensional array and I want to ser...

List of Shapes to Database

I have a generic collection of shapes that I need to pass through WCF to store in a database for future/shared use. Unfortunately, the System.Windows.Shapes are all sealed, so I can't inherit them and make a serializable copy of them. I "could" write my own custom set of serializable shapes, as I have written 3 custom shapes for my app a...

How to customize the soap encoding in Flex Builder 3?

Hello, Friends! I use the Flex Builder 3 to develop a client app for Java Server. The client communicates with the server by means of a WebService. If I work with webservice operations that do not use parameters or use only simple types (String, Number ...) as parameters - all goes well. But If I use operations with complex types such ...

XStream-like XML serialization for Jython objects?

Jython is great for creating custom data structures on need basis, but how to store their instances? Apparently it's possible to do it via java.io.Serializable, but ObjectStreams are not human readable; I would prefer XML. I naïvely tried XStream to serialize a simple object created in Jython and translated to Java with PyObject's __toj...

Serialization of Dictionary embedded deep in object

Hi, I have been trying to serialize a pretty big object. This object uses dictionaries in order to keep track of various data. I am using the binary formatter, and want to be able to easily serialize the whole object whithout interfering/having to change code in the below layers. Is there any way fix to this? I don't want to serialize ...

Serializing a list of anonymous delegates.

This question may be very similar to my one, but I cannot see the answer I need in it. I have a class, called CASM, that has a List<Action>. I want to serialize this class (using the BinaryFormatter or something similar). This class and all classes referenced in the Actions have got correct [Serializable] and [NonSerializable] attributes...

How to delta encode a C/C++ struct for transmission via sockets

Hi, I need to send a C struct over the wire (using UDP sockets, and possibly XDR at some point) at a fairly high update rate, which potentially causes lots of redundant and unnecessary traffic at several khz. This is because, some of the data in the struct may not have changed at times, so I thought that delta-encoding the current C str...

XML Deserialization of Inherited Objects

Hi, I have an object InputFile that has arrays and objects to hold the contents of a file. I also have ABCFile and XYZFile that are both inherited from InputFile that will read different types of file and store them into the projected members of InputFile. Since the serialization and deserialization of both of these objects are identi...

serialize problem in php

I want to serialize a multidimension array in php: $arr['foo'] = array('bar'=>'foo'); I'm going to pass $arr to an eval function and so i needed it to be serialized. When eval runs, it actually passes this as an argument to a class method, call it helper method, this helper method then takes that argument and converts it back to a rea...

How to increase deserialization speed?

Serializing/deserializing with BinaryFormatter, resulting serialized file is ~80MB in size. The deserialization takes a few minutes. How could I improve on this? Here's the deserialization code: public static Universe DeserializeFromFile(string filepath) { Universe universe = null; FileStream fs = new FileStream...

Ruby YAML problem when deserializing a nested object structure

Hello guys, I have 3 classes that have the following relationship: Battlefield have an array of teams. BattleTeam have an array of members, and a reference to the Battlefield. Jaguar is a member of a BattleTeam and has a reference to it. If I serialize/deserialize Jaguar and up to BattleTeam, there is no problem. The problem happens...

Best way to deserialize a long string (response of an external web service)

I am querying a web service that was built by another developer. It returns a result set in a JSON-like format. I get three column values (I already know what the ordinal position of each column means): [["Boston","142","JJK"],["Miami","111","QLA"],["Sacramento","042","PPT"]] In reality, this result set can be thousands of records ...

How to deserialize or recover a binary serialized dictionary that's not finished serializing?

When I used my app, on close, it tried to serialize a dictionary that's 300 KB. Because of no disk space, it could only write 292 KB. Is there a way to successfully deserialize whatever is in there? I used BinaryFormatter and if I lose some elements that's way better than losing the whole dictionary. When I deserialize I get this excep...

Can I implement a generic type and pass it a type that is known only at runtime?

I'm pulling serialized data from a database along with an object type (where one field contains the object type and one contains an XML string of serialized data). I've got a generic serializer that has a serialize and deserialize method: public static class Serializer<T> { public static string Serialize(T objectData) { } publi...