serialization

What is the preferred way to implement serializable classes in C#

I've seen many different ways to serialize objects in C# that I'm not sure which one to use and when. In the current situation I'm serializing for exposure through WCF so I'm guessing the [DataContract] attribute is the way to go. Currently I'm reading in some XML, then exposing the resulting object through WCF. So I am deserializi...

How can I change package for a bunch of java serializable classes

I want to change the packages of multiple classes in my application. A nice eclipse redactor good have been great but some of my classes are Serializables and I need to support cross version compatibility. Any Idea on how it can be done? Can it be done automatically/semi-automatically? ...

How do you desearialize a bool from Xml with custom true and false values?

I am trying to deserialize an Xml document to a C# class. The Xml looks something like this: <response> <result>Success</result> </response> That result can be only "Success" or "Failed". When I deserialize it I want to put the value into a bool with "Success" = true and "Failed" = false. I can't quite figure out how to set the tr...

conversion of uint8_t to sint8_t

Hi folks! What's the best way to convert an "uint8_t" to an "sint8_t" in portable C. That's the code I came up with .... #include <stdint.h> sint8_t DESER_SINT8(uint8_t x) ( return (sint8_t)((x >= (1u << 8u)) ? -(UINT8_MAX - x) : x); ) Is there a better/simpler way to do it? Maybe a way without ...

DataContractSerializer not deserializing all variables

I'm trying to deserialize some xml without having the original class that was used to create the object in xml. The class is called ComOpcClientConfiguration. It's succesfully setting the ServerUrl and ServerUrlHda values, but not rest of them... So what I'm asking is: How can I make the rest of these values get set properly, and why are...

Saving/loading document state quickly and robustly for image editor

I'm looking for some critique on my approach for storing the state of a bitmap editor for Android and iPhone mobile phones. Even a "Looks fine to me!" response would be great! In the application, the current user document contains several bitmap layers (each maybe 1024 by 768 pixels) that can each be painted on. The basic requirements ...

How many variables point to the object and which [.net]

I want to make my own xml-serializer class because I need other formatting than the System.Xml.Serialization.XmlSerializer does. My idea is to treat properties of primitive type (such as Integer, Double, String) as XmlAttributes. To properly implement a usable Xml-Serialization I need to know which variables point to the same object (th...

Using iostream << to serialize user objects

I want serialize object to binary file using operator "<<", but when I serialize, for example, int fields, I obtained it's symbolic representation: ofstream out("file", ios::out | ios::binary); int i=0xAA; out << i; And output: 0x31 0x37 0x30 i.e. (0xAA -> 170) 170 If I use write function, all ok: out.write((char*)&i,sizeof(int...

How can I serialize and deserialize Perl data to/from database?

What is the best module or approach to serialize data into a database? Currently I am looking into Storable functions freeze and thaw, example: use Storable qw(freeze thaw); use strict; my %array_test = ('Year Average' => 0.1, 'Color Average' => 0.8, 'Humans' => 0, 'Units' => 1); my $serialized_data = freeze(\%array_test); my %deseria...

Does "default" serialization in C# serialize static fields?

By "default" I mean just using the [Serializable] attribute on the class. I want to say that no, static fields would not be serialized, but I'm not exactly sure. ...

Why is binary serialization faster than xml serialization?

Why is binary serialization considered faster than xml serialization? ...

Google's Protocol Buffers in c#

We are looking at using Google's Protocol Buffers to handle serialization between a c++ application and a c# application via networking. My question is, I've found a couple of different verisions for c#. Both look pretty good, however, does anyone know what is different (if anything) between the two protobuf-net jskeet / dotnet-proto...

PHP SQLite JSON Data Duplication

I have the following PHP code: $testMessage = "TESTMESSAGE"; $db = new SQLite3('messages.sq3'); $db->exec('CREATE TABLE messages(id INTEGER PRIMARY KEY, message CHAR(255));'); $db->exec("INSERT INTO messages (message) VALUES ('$testMessage');"); $results = $db->query('SELECT * FROM messages ORDER BY id DESC LIMIT 5'); while ($row = $...

Generate two different xml serializations for a .net class

I have a set of .net classes that I currently serialize and use with a bunch of other code, so the format of that xml is relatively fixed (format #1). I need to generate xml in another format (format #2) that's a pretty similar structure but not exactly the same, and am wondering the best approach for this. For example, say these are m...

xml serialization property order

Hi all, just a quick question. I have been looking around searching for information about the order of elements in the serialization xml document for an object. As far as I know the order (unless specified using XmlElement attributes) will be the order the properties are present in the type's code. This order, however, is not guarantee...

Is this a good concept for sending serialized objects over Network?

I have a client and a server I want to send objects from client to server The objects must be send bundled together in a "big packet" containing many objects The objects could be in a random order The number of objects is not fixed There could be objects in the packet which are unknown to the server (so he needs to dump them) I haven'...

Protocol Buffer better than serialization ?

I have a large data-structure which i'm serializing.At certain times i need to edit the values in the data-structure.But just for changing a small value i'll have to re-serialize it again instead of updating the changed value in file.I've heard of Google protocol buffer's.Will using it solve my problem of rewriting the file ? Is it a bet...

How do I pass a JSON object to FullCalendar from Django (by serializing a model)?

FullCalendar supports taking in a JSON object through AJAX for it's events, this can be done on initialization or later like this: $('#calendar').fullCalendar('addEventSource', "/{{ user }}/events/" ); The serialization itself in my Django view looks like this: ... events = Event.objects.filter(user=request.user, start__gte=start, en...

Creating own implementation of Boost::Archive

I'm currently creating a concept which uses Boost::Serialization and which needs to implement its own Boost::Archive cause the data has to be serialized in a certain way. There is documentation about implementing custom archives in the documentation: http://www.boost.org/doc/libs/1_44_0/libs/serialization/doc/index.html But I'm curious...

Deserializing self-tracking entity with nested TrackableCollection

How can I deserialize JSON string into entity of type like this (self-tracking properties removed to be simple): public class User: { int Id { get; set; } string Name { get; set; } public TrackableCollection<Role> Roles { get; set; } // <! } Role is also simple class with two properties. TrackableCollection is descendant ...