serialization

Managing serveral versions of serialized Java objects.

Lets say that I have a program that for some reason need to handle old versions of serialized objects. Eg: when deserializing, one of these versions may be encountered. class Pet { private static final long serialVersionUID = 1L; int paws; } class Pet { private static final long serialVersionUID = 2L; long paws; // han...

Easy JSON encoding with Python

Hi, I'm quite new to python (I use python 3), and i'm trying to serialize a class with one string and two lists as members in JSon. I found that there's a json lib in the python standart but it seems that I need to manually implement a serialization method. Is there a JSon encoder where I can simply pass an object, and receive the serial...

XmlElementName - Change during runtime

I am implementing a class object that is serializable. something like this: StringWriter sw = new StringWriter(); XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); ns.Add("", ""); System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(this.GetType()); ...

Missing the end of the XML when serializing with DataContractSerializer

I have the following method that I use to serialize various objects to XML. I then write the XML to a file. All the objects have the proper [DataContract] and [DataMember] attributes. public static string Serialize<T>(T item) { var builder = new StringBuilder(); var serializer = new DataContractSerializer(typeof(...

How to serialize beautifulsoup access-paths?

i have code, which does something like this: item.previous.parent.parent.aTag['href'] now i would like to be able to add filters fast, so hardcoding is no longer an option. how can i access the same tags with a path coded in a string? of course i could invent some format like [('getattr', 'previous'), ('getattr', 'parent'), ..., ('ge...

How can I exclude the Type information from the DataContract?

I want to exclude the __type Key and Value from my serialization: {"__type":"Entity:#Runtime.DataBus","Children":[],"Fields":[{"Key":"field1","Value":"10"},{"Key":"fieldString1","Value":"field1 init"},{"Key":"fieldString2","Value":"field2 init"}],"Name":"Entity1"} I'm using the System.Runtime.Serialization.Json.DataContractJsonSeriali...

How can I pass complex types like objects using Webservices ?

Hi, This may sound like a simple question but as am newbie in Webservies and this is my first time using it and so am asking my doubt. Q: How can I pass objects or complex types using Web Services ? I have created a simple webservice and am passing string and integer types but I am not sure how can I pass objects using webservice and...

C# Serialize Dictionary<ulong,ulong> to JSON

I am trying to serialize a Dictionary to JSON, and get the following exception: new JavaScriptSerializer().Serialize(mydict) Type 'System.Collections.Generic.Dictionary2[[System.UInt64, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Nullable1[[System.UInt64, mscorlib, Version=2.0.0.0, Culture=neut...

How to make System.Drawing.Color both serializable and editable with propertygrid?

Basically i have a settings class like this: class Settings { Color BackgroundColor {get;set;} Color ForegroundColor {get;set;} Color GridColor {get;set;} Color HighlightColor {get;set;} //... etc } And i want to be able to do both - serialize the settings class and edit the colors in propertygrid. The solution I've come ...

unserialize() function does not work on a variable from the MySQL table on new server

We just switched our website over to a new server. There is a part of my PHP software that pulls out a serialized data value from the MySQL table, and puts it into a variable, and then it's supposed to unserialize(). I never had this issue on any other servers (and this exact code is used on many different servers..), but I'm getting an...

With java/j2ee, how does serialization work and in relation to saving that object in session?

If I have a complex object with hundreds of String fields and objects of objects. Some are implementing Serializable and some aren't. How would a j2ee server serialize that data in session. Would I expect all data to be returned. Even the objects of objects. Session.setAttribute(data) E.g. Session.getAttribute() == data.getData().g...

Is serialized object compatible in all version of java?

My friend asked me if we serialize an object in java 1.5 and then deserialize it back in java 1.6 then it will throw an exception. What is that exception and why that is thrown? But i doubt there will be any exception. Reason being nothing is changed in class definition, so it should not face any problem in rebuilding the object back f...

Cannot deserialize JSON array into type foo

I am trying to parse out data from oodle.com api feed using the JSON.NET lib. Part of the response JSON string to deserialize has the following 'location' structure: "location":{ "address":"123 foo Street", "zip":"94102", "citycode":"usa:ca:sanfrancisco:downtown", "name":"San Francisco (Downtown)", "state":"CA", "country":"USA", "latitu...

Working around unexpected behavior in yaml for Ruby -- interned unicode strings

(1.9 on Windows) Reproducing: require 'yaml' s = YAML::load("\xEC\x86\x8C\xEB\x85\x80\xEC\x8B\x9C\xEB\x8C\x80") # => "∞åîδàÇ∞ï£δîÇ" or "소녀시대", depending on your terminal's unicode support s_interned = s.intern s_interned.class # => Symbol s_yamld = s_interned.to_yaml # => "--- \":\\xEC\\x86\\x8C\\xEB\\x85\\x80\\xEC\\x8B\\x9...

Class with [Serializable] Attributute

Possible Duplicate: Does adding [Serializable] to the class have any performance implications? What is the drawback of this attribute? Many of my data objects (DTO) have this attribute because I use to store objects in ViewState. Is there any performance issue regarding this attribute? ...

Deserializing Data in Java

I'm trying to read in player data from an array list, but after 2 hours of searching and experimenting, I'm lost. Here's the deserializing code. It's commented, but basically there should be a file with a Serialized ArrayList of Player objects. I want to deserialize that data and store it in savedPlayers, and then use savedPlayers for a...

Serializing wchar_t* in a struct with TPL

Hello all, I'm trying to use tpl to serialize structs that contain wchar_t* strings. The code I have looks like this, and it's not working: #include <stdio.h> #include <locale.h> #include <string.h> #include <wchar.h> #include "tpl.h" struct chinese_t { wchar_t *chars; }; int main() { tpl_node *tn; struct chinese_t cstr; cstr...

How to re-attach an object to EclipseLink session after deserialization

Here's a simple POC: public void main(String[] args) { final String FILE_NAME = "c:/poc.ser"; try { HotelJdo hotel = HotelJdoFinder.findById(430); ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(FILE_NAME)); // serialize the object oos.writeObject(hotel); oos.close(); ...

how can I consume django web service in C# ?

python - django webmethod returns simplejson.dumps, how can I convert the simplejson string into C# 2.0 Object ? for example, dict -> Hashtable string -> String ... is there any JSON Serializable library in existing .NET framework or any 3rd party tool ? ...

Disposing objects added using AddValue of SerializationInfo

How can I make sure that the objects get disposed that I am adding into the SerializationInfo object? For example: if I am adding a hashtable to the info object, how do I make sure that after serialization, there is no reference alive to the hastable object of my class and I can free the memory somehow? info.AddValue("attributesHash", ...