serialization

Programmatically set properties to exclude from serialization

Is it possible to programmatically set that you want to exclude a property from serialization? Example: When de-serializing, I want to load up an ID field When serializing, I want to NOT output the ID field (it's a silly example, but hopefully it's clear) ...

How can I have a serializable struct that wraps it's self as an int32 implicitly? in C#?

Long story short, I have a struct (see below) that contains exactly one field: private int value; I've also implemented implicit conversion operators: public static implicit operator int(Outlet val) { return val.value; } public static implicit operator Outlet(int val) { return new Outlet(val); ...

XML serialization query

I have the following XML which needs deserializing/serializing: <instance> <dog> <items> <item> <label>Spaniel</label> </item> </items> </dog> <cat> <items> <item> <label>Tabby</label> </item> </items> </cat> </instance> I cannot change the XML structure. I need ...

Flex: How do you list private attributes of a class?

Hi, I try to serialize objects with their private attributes, in Flex. The introspection API does not seem to allow it: "The describeType() method returns only public members. The method does not return private members of the caller's superclass or any other class where the caller is not an instance." Is there another way for an insta...

Properly obsoleting old members in an XML Serializable class in C# VB .NET

Hi! Sometime ago I defined a class that was serialized using XML. That class contained a serializable property Alignment of integer type. Now I have extended and updated this class, whereby a new property Position was added, whose type is another class that also has several serializable properties. The new property Position is now suppos...

Boost Binary Serialization Problem

Hi all, I have a problem using boost serialization using binary archives. It works when using a file stream but I want to store it in my local variable and ultimately save/load it to/from berkeley db. When executing the program I get a *boost::archive::archive_exception*: 'stream error' when instantiating the *binary_iarchive*. #inclu...

WCF MessageContract Help - MessageBodyMember with hyphenated name

Hi All, I need a bit of WCF help. This project uses message contracts. The transport seems to work ok. I have this code for a response type. namespace tpoke.Contracts { [MessageContract(IsWrapped = true)] public class AuthenticationResponseMC { [MessageBodyMember(Name = "authentication-token")] public Guid Authenticatio...

Java. Best procedure to de-serialize a Java generic object?

What is the best procedure for storing and retrieving, using native Java serialization, generic objects like ArrayList<String>? Edit: To clarify. When I serialize an object of type ArrayList<String> I'd like to de-serialize to the same type of object. However, I know of no way to cast back to this generic object without causing warni...

Decompressing a very large serialized object and managing memory

I have an object that contains tons of data used for reports. In order to get this object from the server to the client I first serialize the object in a memory stream, then compress it using the Gzip stream of .NET. I then send the compressed object as a byte[] to the client. The problem is on some clients, when they get the byte[] a...

TypeConverter for serialization

Is it normal practice to use a TypeConverter for serialization? There is a class that I do not own that has a "lossy" TypeConverter. When converting to a string, it formats its floating point data with "G4", so that when this type is displayed in a PropertyGrid, it's easily readable. I would like to also use this TypeConverter to conve...

How can I return json from my WCF rest service (.NET 4), using Json.Net, without it being a string, wrapped in quotes?

UPDATE 10/19/2010 I know I asked this question a while ago, but the workarounds shown in these answers are hardly satisfactory, and this is still a common problem for many. WCF just isn't flexible. I started my own open source C# library for creating REST services without WCF. Check restcake.net or rest.codeplex.com for info on said l...

What is the best way to interoperably serialize a message?

I'm considering message serialization support for spring-integration. This would be useful for various wire level transports to implement guaranteed delivery, but also to allow interoperability with other messaging systems (e.g. through AMQP). The fundamental problem that arises is that a message containing Java object in it's payload a...

How to customize the process employed by WCF when serializing contract method arguments?

Dear ladies and sirs. I would like to formulate a contrived scenario, which nevertheless has firm actual basis. Imagine a collection type COuter, which is a wrapper around an instance of another collection type CInner. Both implement IList (never mind the T). Furthermore, a COuter instance is buried inside some object graph, the root o...

Rails: How do I unserialize from database?

Hello, I am currently trying to save information for an invoice/bill. On the invoice I want to show what the total price is made up of. The procedures & items, their price and the qty. So in the end I hope to get it to look like this: Consult [date] [total_price] Procedure_name [price] [qty] Procedure_name [price] [qty] ...

Not sure how to get an object to display after loading from ObjectInputStream()

public void load() { final JFileChooser fc = new JFileChooser(); int returnVal = fc.showOpenDialog(this); if(returnVal == JFileChooser.APPROVE_OPTION) { try{ FileInputStream f_in = new FileInputStream(fc.getSelectedFile()); ObjectInputStream obj_in = new ObjectInputStream(f_in); ...

XML Deserialization

I have the following xml file. <a> <b> <c>val1</c> <d>val2</d> </b> <b> <c>val3</c> <d>val4</d> </b> <a> I want to deserialize this into a class and I want to access them with the objects of the class created. I am using C#. I am able to deserialize and get the value into the object of class ‘a’ (the <a> tag). ...

WCF Bidirectional serialization fails

I'm trying to take advantage of Bidirectional serialization of some relational Linq-2-Sql generated entity classes. When using Unidirectional option everything works just fine, bu the moment I add IsReferenceType=true, objects fail to get transported over the tcp binding. Sample code: Entity class: [Table(Name="dbo.Blocks")] [DataCo...

How can I implement partial serialization?

I've done a lot of serialization development lately, mostly for sending objects over sockets, but I've run into an interesting question: Is it possible to send just a few of the properties from an object through a serializer? My envisioned scenario is this: You have some sort of "state" object for each client, consisting of many propert...

How to serialize a list with multiple data types in C# from xml?

I want to deserialize/serialize the following XML into an object. <Discounts> <Discount Type="Voucher" Key="ABCD00001" Percent="2" /> <Discount Type="Quantity"> <Periods> <Period From="Thu, 31 Dec 2009 23:00:00 GMT" Quantity="1" /> <Period From="Thu, 31 Dec 2009 23:00:00 GMT" Quantity="2" /> ...

IDL-like parser that turns a document definition into powerful classes?

I am looking for an IDL-like (or whatever) translator which turns a DOM- or JSON-like document definition into classes which are accessible from both C++ and Python, within the same application expose document properties as ints, floats, strings, binary blobs and compounds: array, string dict (both nestable) (basically the JSON type fe...