serialization

How does Google Protocol Buffers compare to ASN.1

What are the most noticable differences between Google Protocol Buffers and ASN.1 (with PER-encoding)? For my project the most imporant issue is the size of the serialized data. Has anyone done any data-size comparisons between the two? ...

Deserialization problem with DataContractJsonSerializer

I've got the following piece of JSON: [{ "name": "numToRetrieve", "value": "3", "label": "Number of items to retrieve:", "items": { "1": "1", "3": "3", "5": "5" }, "rules": { "range": "1-2" } }, { "name": "showFoo", "value": "on", "label": "Show foo?" }, { "name...

How can I get a reference to the parent object when deserializing XML in C#?

I can't seem to get this working, here is my (stripped down) code: - [XmlRoot("report")] public class Report { [XmlArray("sections"), XmlArrayItem("section")] public List<Section> Sections; } public class Section { public Report Report; } Am I missing something? ...

Java Object Serialization Performance tips

I must serialize a huge tree of objects (7,000) into disk. Originally we kept this tree in a database with Kodo, but it would make thousands upon thousands of Queries to load this tree into memory, and it would take a good part of the local universe available time. I tried serialization for this and indeed I get a performance improveme...

ISerialization Constructor not getting called

EDIT: The solution to my problem is to implement IXMLSerializer. Thanks everyone for the quick responses. Hi everyone, I'm having this issue and I do not seem to a find a proper solution to it. I have the following class public class Child { private int _id; public int Id { get { return _id; } set...

Can I add attributes to an object property at runtime?

For example I want to remove or change below property attributes or add a new one. Is it possible? [XmlElement("bill_info")] [XmlIgnore] public BillInfo BillInfo { get { return billInfo; } set { billInfo = value; } } ...

Is it possible to serialize objects without a parameterless constructor in WCF?

I know that a private parameterless constructor works but what about an object with no parameterless constructors? I would like to expose types from a third party library so I have no control over the type definitions. If there is a way what is the easiest? E.g. I don't what to have to create a sub type. Edit: What I'm looking for is...

Web service cast exception why?!

Error Cannot implicitly convert type 'string[]' to 'System.Collections.Generic.List<string>' The above error is caused when I call a method to a web service List<string> bob = myService.GetAllList(); Where: GetAllList = [WebMethod] public List<string> GetAllList() { List<string> list .... r...

Does it matter what I choose for serialVersionUID when extending Serializable classes in Java?

I'm extending a class (ArrayBlockingQueue) that implements the Serializable interface. Sun's documentation (and my IDE) advises me that I should set this value in order to prevent mischief: However, it is strongly recommended that all serializable classes explicitly declare serialVersionUID values, since the default serialVersionUID ...

C# serialization issue

I am confused about the serialization sample from MSDN, http://msdn.microsoft.com/en-us/library/system.runtime.serialization.iserializable.getobjectdata.aspx My confusion is, in method GetObjectData (which is called during serialization), will the method, (1) serialize both the additional data (in method GetObjectData from AddValue) a...

C# Designer Serialisation problems

I've been having some problem serializing my objects and have narrowed the problem down to a specific case (see code below). I was getting the following error: Error 1 Invalid Resx file. Could not load type Serialisation.Harness.Blob, Serialisation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null which is used in the .RESX file. ...

Ruby on Rails Advanced JSON Serialization

I'm looking to render an index of all articles along with a full article via json in my rails app, but I'm having a little trouble figuring out how to do it. Here is my controller now: if params[:id] @article = Article.find(params[:id]) else @article = Article.published.not_draft.by_recent.first end respond_to do |format| for...

Is it possible to deserialize XML into List<T>?

Given the following XML: <?xml version="1.0"?> <user_list> <user> <id>1</id> <name>Joe</name> </user> <user> <id>2</id> <name>John</name> </user> </user_list> And the following class: public class User { [XmlElement("id")] public Int32 Id { get; set; } [XmlElement("name")] public Strin...

Implementing friend (available in C++) functionality in C#

Ok, let's leave the debate of whether friendship breaks encapsulation, and actually try elegantly come up with a coherent design. It is a two fold function: 1) General question on how to implement: public class A { friend class B; } 2) Why do I need this functionality? Some of my classes implement ISerializable inter...

What can cause properties in an .NET Service Reference to become null on invocation?

I just had a laptop crash (spilled water on it). I copied my working code (2 days ago backup) from a Windows Server 2008 laptop to a Vista laptop running Visual Studio 2008 SP1. Both are running .NET 3.5 SP1. I have a web method call which is returning product information. Some of the fields in the web service (running on a hosted serv...

Is there a tool to capture an objects state to disk?

What I would like to do is capture an object that's in memory to disk for testing purposes. Since it takes many steps to get to this state, I would like to capture it once and skip the steps. I realize that I could mock these objects up manually but I'd rather "record" and "replay" real objects because I think this would be faster. Edi...

Best practice to serialize and deserialize .net objects across versions

Objects are serialized to a database using the .NET XML serializer. The object can change over time, and therefore multiple versions exist in the database at one time. Any suggestions for the best way to construct your code, so that you can still deserialize this object into the latest version. (interfaces / maps / manual serialization ...

How to exclude nonserializable observers from a [Serializable] INotifyPropertyChanged implementor?

I have almost a hundred of entity classes looking like that: [Serializable] public class SampleEntity : INotifyPropertyChanged { private string name; public string Name { get { return this.name; } set { this.name = value; FirePropertyChanged("Name"); } } [field:NonSerialized] public event Propert...

casting to multiple (unknown types) at runtime

I'm developing a viewer that will be able to open all of the custom documents that we produce via our software. All of the documents inherit from IDocument, but I'm not sure how to go about deserializing (in a good way - nested try/catch could probably work, but that would be hideous). So my method as it is now looks like this: public...

I get this JavaScriptSerializer.Deserialize Exception, how do I fix it?

System.Exception: There was an error reading the city list for CANANDA ---> System.ArgumentException: Unrecognized escape sequence. (1056): {code: "CA",cities: [{name: "Abbotsford",lat: 49029998,lon: -122370002},{name: "Calgary",lat: 51119998,lon: -114019996},{name: "Edmonton",lat: 53299999,lon: -113580001},{name: "Halifax",lat: 448800...