serialization

How to specify the order of XmlAttributes, using XmlSerializer

XmlElement has an "Order" attribute which you can use to specify the precise order of your properties (in relation to each other anyway) when serializing using XmlSerializer. Is there a similar thing for XmlAttribute? I just want to set the order of the attributes from something like <MyType end="bob" start="joe" /> to <MyType star...

ISerializable and OnSerializingAttribute

I have a type that both implements ISerializable and defines a method adorned with the OnSerializingAttribute. I have noticed that ISerializable.GetObjectData is called before the OnSerializing callback. This seems wrong to me because it renders the OnSerializing callback redundant. After all, there's no point in making preparatory ad...

WCF Deserialization Error

ERROR - Exception: System.ServiceModel.Dispatcher.NetDispatcherFaultException Message: The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter services.gmrlive.com/JupiterMobile/2009/01/01/:StatusDetails. The InnerException message was 'There was an error deserial...

Print and array to a file..

Hi, I would like to print an array to a file. I would like the file to look exactly similar like how a code like this looks. print_r ($abc); assuming $abc is an array. Is there any one lines solution for this rather than regular for each look. P.S - I currently use serialie but i want to make the files readable as readability is qui...

How to serialize Java primitives using Jersey REST

In my application I use Jersey REST to serialize complex objects. This works quite fine. But there are a few method which simply return an int or boolean. Jersey can't handle primitive types (to my knowledge), probably because they're no annotated and Jersey has no default annotation for them. I worked around that by creating complex ty...

Get a class name with generics information

Hello, In a java serialization problem, I want to save some classes name and I have some problems with generic classes. For example : - If I have ArrayList<String> listToDump = new ArrayList<String>(); - If I take the name : listToDump.getName(); or listToDump.getCanonicalName(); - I will have java.util.ArrayList or ArrayList - And I wan...

Android Hashtable Serialization

Hi All, I am having a weird issue with serialization of a Hashtable. I have made a Server, Client app. Where server(PC/MAC) is serializing a Hashtable and sending it to Client(Android) through UDP. The data is sent/read correctly but I get a bunch of these messages below on LogCat. 04-12 11:19:43.059: DEBUG/dalvikvm(407): GetFieldID:...

Issue with JSON and jQuery

I'm calling a web service and returning the following data in JSON format: [{"OrderNumber":"12345","CustomerId":"555"}] In my web service success method, I'm trying to parse both: $.ajax({ type: "POST", url: "MyService.asmx/ServiceName", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json",...

Deserialize an observablecollection to this reference

Seems like there should be an easy one-liner here: Within my ObservableCollection derived class I binary serialize it to disk: binFormatter.Serialize(stream, this); How do I deserialize to my this object reference: This does not work: this = binFormatter.Deserialize(stream) as MyAwesomeData; Do I need to Clear the collection and add....

Data denormalization and C# objects DB serialization

I'm using a DB table with various different entities. This means that I can't have an arbitrary number of fields in it to save all kinds of different entities. I want instead save just the most important fields (dates, reference IDs - kind of foreign key to various other tables, most important text fields etc.) and an additional text fie...

How can we serialize a class that is not a custom class of our own?

I need to look at the properties of an object and I cannot instantiate this object in the proper state on my dev machine. I need my client to run some code on her machine, serialize the object in question to disk and then I can analyze the file. Here is the class I want to serialize. System.Security.AccessControl.RegistrySecurity Her...

Serialize checkbox array, also get checkboxes with off-value

Hi, I was wondering if this is possible. The serialize-string will be inserted in a mySQL-database, so it would be fine if all checkboxes would be inserted and not only the ones that is ticked(on). it's possible to make on column in the database for each of the checkboxes, and use this if/else-statement: if(isset($_GET['checkbox'])) {...

Why are interfaces not [Serializable]?

I would think that adding that attribute to an interface would be helpful make sure you do not create classes that use the interface and forget to make them serializable. This could be a very fundamental question, but I wanted to ask the experts. ...

How to get DataTable to serialize better?

I have the following code that serializes a DataTable to XML. StringWriter sw = new StringWriter(); myDataTable.WriteXml(sw); And this works, however, the serialized XML looks like this: <NameOfTable> <NameOfTable> <ID>1</ID> <Name>Jack</Name> </NameOfTable> <NameOfTable> <ID>2</ID> <Name>F...

Where to locate the unattend.xml schema

I'm in need of a way to modify an unattend.xml file programmatically. It would be great if I could just serialize to and from an object. But to do so I would need to get a hold of the schema so that I can run it through XSD. The referenced link provides all the possible settings but it would be nice to have it in XSD format. Any ideas? ...

Serialize Linq objects not working

Using the following code: Private Sub MakeMeSomeXmlBeforeRyanGetsAngry() Dim db As New MyDBDataContext Dim customer = From c In db.Customers Select c Dim dcs As New DataContractSerializer(GetType(Customer)) Dim sb As StringBuilder = New StringBuilder Dim writer As XmlWriter = XmlWriter.Create(sb) dcs.Writ...

Is that a RESTFUL MVC Web Service?

I am aware of Web Services and WCF but I have generic question with services. I have a ASP.NET MVC Application which does some basic functionality. I just have a controller in which I am passing it the records and serializing the information to XML using XML Serializer. Then I return this information to the browser and it displays me ...

Serialize a java.awt.geom.Area

Hi all, I have the need to serialize an Area object (java.awt.geom.Area) in a socket. However it doesn't seem to be serializable. Is there a way to do such thing? Maybe by converting it into a different object? Thanks in advance ...

Byte array serialization in JSON.NET

Given this simple class: class HasBytes { public byte[] Bytes { get; set; } } I can put it through JSON.NET such that the byte array is base-64 encoded: var bytes = new HasBytes { Bytes = new byte[] { 1, 2, 3, 4 } }; var json = JsonConvert.SerializeObject(bytes); Then I can read it back again in this slightly over-complicated w...

Can I serialize an object if I didn't write the class used to instantiate that object?

Hello, I've a simple class [Serializable] public class MyClass { public String FirstName { get; set: } public String LastName { get; set: } //Bellow is what I would like to do //But, it's not working //I get an exception ContactDataContext db = new ContactDataContext(); public void Save() { Contact contact = new Co...