serialization

Formatting the Json serializarion in a .NET Web Service

Hi everybody, I have the following .NET web service with the following signature (IServices.cs): [OperationContract] [WebInvoke(Method = "GET", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json)] string ReturnListOfPersons(); The implementation is (in the Services...

How can I add a XML prefix to fields in WCF Message Serialization?

How can I add a XML prefix to fields in WCF Message Serialization? I'm connecting up to a Java Spring web service from .NET, and an object that I pass in with parameters is being serialized as you would expect: <MyClass> <field1>Field 1 Value</field1> <field2>Field 2 Value</field2> </MyClass> However, the web service requires tha...

Rails 3 Serialize

Hello, I'm looking to learn how to serialize data in Rails 3... Things I'd like to learn: A. What serialized data looks like (example for photo_id: 123123, photo_name: "Blah) B. How to serialize data in Rails 3 C. How to extract serialized data to do something like mydate.photo_id given the above. Thanks! ...

Json.NET - Value-type members not getting deserialized?

I've been toying around with Json.NET and I'm liking it a lot. However, I've run into a problem when deserializing objects with value-type members. For example, consider this code: public struct Vector { public float X; public float Y; public float Z; public override string ToString() { return string.Format(...

Serilization and Deserialization with .Net

I was currently discussing with a few friends on how to design easily serializable and deserializable classes. We are currently using a "home grown" attempt involving lots of spooky interfaces, custom attributes and loads of reflection which has by now outgrown the extend it was designed for. So we are looking for alternatives. Preferabl...

Array serialization performance issue

In my Windows Mobile (.NET Compact Framework) application I use a big array to store the application's primary data. This is a dataset of potentially hundreds of objects. Each object has about 10 or so properties and two arrays of itself, each with about 25 other objects, each of which has about 5 properties. To save this array on the m...

how to test in Java that a class implements Serializable correctly (not just is an instance of Serializable)

I am implementing a class to be Serializable (so it's a value object for use w/ RMI). But I need to test it. Is there a way to do this easily? clarification: I'm implementing the class, so it's trivial to stick Serializable in the class definition. I need to manually serialize/deserialize it to see if it works. I found this C# question...

WCF Serialization problems with WSDL file created by Java tools

Hi all, My team is tasked with getting several in-house developed .NET client applications to connect to some new Java web services. The Java web service is a third party, vendor supplied WSDL file that our team has a limited ability to modify/control...meaning we probably have the power to request our vendor to make slight tweaks to th...

Serializing objects in C# 4.0, is there a simpler way?

When set up an object for serialization I do the following: [Serializable] public class ContentModel { public int ContentId { get; set; } public string HeaderRendered { get; set; } public ContentModel() { ContentId = 0; HeaderRendered = string.Empty; } public ContentModel(SerializationInfo info,...

What is the most versatile array to string serialization method?

I'm particularly interested in the following features: possibility of modifying the serialized array using regular expressions or other simple methods, being able to parse the string using standard tools in various programming languages, serialization of simple arrays as well as associative arrays (objects), conciseness and human reada...

How should I serialize code references in Perl?

I wish to nstore a Perl hash which also contains a code reference. Following this perldoc I wrote something like this: use strict; use warnings; local $Storable::Deparse = 1; my %hash = (... CODE => ...); nstore (\%hash, $file); I get a warning saying Name "Storable::Deparse" used only once: possible typo at test4.pl line 15.. I gues...

How can I serialize a closure in Perl?

I think this might be best asked using an example: use strict; use warnings; use 5.010; use Storable qw(nstore retrieve); local $Storable::Deparse = 1; local $Storable::Eval = 1; sub sub_generator { my ($x) = @_; return sub { my ($y) = @_; return $x + $y; }; } my $sub = sub_generator(1000); say $sub->(...

Problem Converting Object to XML in C#

Hello All , I have The Following Structure public class GraphData { private List<RecordPerDay> recordPerDay; public List<RecordPerDay> RecordPerDay { get { return recordPerDay; } set { recordPerDay = value; } } } public class RecordPerDay { private string da...

Problem With \ When Converting object to XML

I have a problem when I convert an object to XML. The result is like <Entry From=\"08:46:07\" To=\"20:47:06\" TypeId=\"1\" /> and I want to remove the \ in the XML. How can I do this? ...

Removing / Ignoring Session items that will cause .NET deserialization errors

I'm trying to be clever by allowing a small validation method to be defined "inline" in ASCX templates as an Action<,>, like so: <%= OnValidation(delegate(FormSubmission form, FormResult errors) { // form checks in here, append errors to errors variable if required }) %> It actually works a treat, but in order to ensure it can be ...

ViewScoped Bean cause NotSerializableException

Hello I'm using a ViewScoped Bean the Problem is that when call it I get the NotSerializableException. This is the code of my Managed Bean : @ManagedBean(name="demandesBean") @ViewScoped public class DemandesBean implements Serializable { private static final long serialVersionUID = 1L; @ManagedProperty(value="#{demandeService...

Multi level Xml Array produces xsi:nil="true" instead of Attribute Name in Soap Document

When I do like this [XmlType("c1")] [XmlRoot("c1")] public class Class1 { [XmlArray("items")] [XmlArrayItem("c2")] public Class2[] Items; } [XmlType("c2")] public class Class2 { [XmlAttribute("name")] public string Name; } I get this <soap:Body> <HelloWorld xmlns="http://tempuri.org/"&gt; <c1> ...

How To Deserialize Missing Boolean Field to TRUE

I'm deserializing a custom object from a file to an object in my app using the XmlSerializer. My issue is that I want a field in the object to default to "True" rather than "False" for a new property that doesn't exist in the file that I am deserializing from. By default, .Net is assigning this value to be false because it doesn't exis...

Generate XSD for SOAP messages

I'm consuming a classic Web Service using .NET. Is it possible to automatically generate a XSD for the messages from client to service? The service proxy can be generated using svcutil but I would like to use XML serialization for the actual messages. Right now the service methods take XML strings as parameters whereas I want to use obje...

Rails Serialized Data Validations

I have a field that is serialized to YAML through the default AR behavior. It is currently in an Array of Hashes for examples: [{'name' => 'hi', 'url' => 'bye'}, {'name' => 'hi', 'url' => 'bye'}, {'name' => 'hi', 'url' => 'bye'}] Is there a way I can use some basic AR validations on some of these fields? ...