serialization

DataContractSerializer: How to serialize classes/members without DataContract/DataMember attributes

DataContractSerializer requires classes and members to be marked with the DataContract and DataMember attributes. However, in my case the classes are auto-generated with the EFPocoAdapater framework and these attributes are not present. How can I force serialization of all members using the DataContractSerializer without these attribut...

XML Schema for class containing a DataTable

I have one class which has field of type DataTable. I want to write XSD for this class. My problem is the datable structure is not fixed. The columns are added dynamically. How to write XSD for such a class? Once the XSD is defined, I want to validate the class serialized to XML against the XSD. ...

How to tell C# to omit creation of attributes that are default during serialization?

I have a class that is serialized to a XML file. There are several properties that are rarely used but always created. If I delete them within the XML the deserialization still works, because they have the default value. These unnecessary (bool) attributes make the XML harder to read. Can I somehow tell C# to omit elements or attribut...

Boost serialization in Qt: is it a proper way?

I'm thinking about serializing data in an application which is Qt-based. Essentially what I'm going to serialize is my hierarchical model, which is composed of different classes that derive from, say, TreeModelItem: class TreeModelItem { protected: QList<TreeModelItem *> m_children; //... }; Should I study boost::serialization an...

Serialize DetachedCriteria with nHibernate

I am trying to serialize a DetachedCriteria so I can save it in a database and reuse the same criteria at a later date. When I run the code below I get "NHibernate.Criterion.DetachedCriteria cannot be serialized because it does not have a parameterless constructor". DetachedCriteria criteria1 = DetachedCriteria.For<SecurityObjectDTO>("...

DataContractJsonSerializer and Enums

When I serialize a enum value using DataContractJsonSerializer, it serializes the numerical value of the enum, not the string name. IE: enum foo { bar, baz } Serializing a value of foo.bar returns "0", not "bar". I'd prefer it the other way around, is there a way to override this? Edit: Because I didn't want to change the ...

How to deserialize an object persited in a db now when the obect has different serialVersionUID

My client has an oracle data base and an object was persisted as a blob field via objOutStream.writeObject, the object now has a different serialVersionUID (even though the object has no change, maybe different jvm version) and when they try to de-serialize an exception is thrown: java.io.InvalidClassException: CommissionResult; local c...

C# Compact Framework - OutOfMemoryException with XmlSerializer.Serialize

Hi everyone, I'm trying to serialize a large collection of objects (20,000) objects within the collection. I'm doing this using the following code: XmlSerializer xs = new XmlSerializer(deserialized.GetType()); StringWriter sw; using (sw = new StringWriter()) { xs.Serialize(sw, deserialized); // OutOfMemoryException here } string ...

Linq to SQL vs Serialization

Say I have a few tables in the MSSQL database, each with about 5-10 attributes. There are some simple associations between the tables, but each of the table have 500,000 to 1,000,000 rows. There is an algorithm that runs on that data (all of it), so before running the algorithm, I have to retrieve all the data from the database. The alg...

How do I JSON serialize a Python dictionary?

I'm trying to make a Django function for JSON serializing something and returning it in an HttpResponse object. def json_response(something): data = serializers.serialize("json", something) return HttpResponse(data) I'm using it like this: return json_response({ howdy : True }) But I get this error: "bool" object has no at...

Problem with rss reading

Hello Everyone, I have a problem with reading an rss feed in my site. When i add an feed to my site I cache it in the database by serializing it and when I do a refresh I unserialize it again from the database if it is within a certain time limit. Else I read again the feed from the remote site. I think the problem has to do with th...

Serializing private member data

I'm trying to serialize an object to XML that has a number of properties, some of which are readonly. public Guid Id { get; private set; } I have marked the class [Serializable] and I have implemented the ISerializable interface. Below is the code I'm using to serialize my object. public void SaveMyObject(MyObject obj) { XmlSeri...

How to serialize on to existing file?

Let say I have a file that contains a serialized object by BinaryFomatter. Now I want to be able to serialize another object and APPEND this on that existing file. How can I do it? ...

Preferred method to store PHP arrays (json_encode vs serialize)

I need to store a multi-dimensional associative array of data in a flat file for caching purposes. I might occasionally come across the need to convert it to JSON for use in my web app but the vast majority of the time I will be using the array directly in PHP. Would it be more efficient to store the array as JSON or as a PHP serialized...

custom serialization converters for a WCF service

We are currently using a .asmx web service method which serializes our object to Json to be returned to the client and consumed by MS Ajax code. For some members of the object, we use custom converters via classes that derive from JavaScriptConverter and override the Serialize method. We "wire up" these custom converters in our web.con...

Can I use NHibernate to store an object in xml serialized form?

Say I have a class like this: public class MyClass { public int Id { get; set; } public DateTime Date { get; set; } public string String1 { get; set; } public string String2 { get; set; } public string String3 { get; set; } public string String4 { get; set; } } Is it possible to get NHibernate to store it in t...

SoapFormatter versioning problem

In the application(C#) I am maintaining, there are some serialized object stored in the database, and some are created several versions ago. Now when the app tries to deserialize those objects, it throws an exception: Parse Error, no assembly associated with Xml key .... (the assembly name and version) As I understand it, when the Soap...

How to make the Asp.Net/WSE asmx page generator add the base class properties in a derived class

I have a simple base class B with 2 public properties. This class is inherited by another class D that adds another public property. The derived class is returned by a web service call. The page generated by ASP.Net looks like: '''<remarks/> <System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.3074"), _ Sys...

Refactoring class to interface without breaking serialization in Csharp

i have a class that i have serialized to disk on local users machines. I need to refactor this class and i changed all objects (anything except enums, string, numbers) to interfaces. Underneath it is still the same concrete class. my concern is breaking existing users persistance From: public class Foo { public double Count; ...

Is there ANY way to save a graph object containing nodes and edges?

I've tried using the standard serializing type things, stuff like: FileOutputStream f_out; try { f_out = new FileOutputStream("MAOS.data"); ObjectOutputStream obj_out = new ObjectOutputStream (f_out); obj_out.writeObject(s); obj_out.flush(); obj_out.close(); } catch (FileNotFoundException e) { // TODO Auto-generated c...