I'd prefer to use Microsofts System.Runtime.Serialization.Json.DataContractJsonSerializer
to serialize my objects in JSON so I do not have to reference any third party assemblies.
I'm trying to serialize arrays into a JSON string. There maybe just 1 array, with every other entry being the name and other being the value.
e.g.[ "name1", "...
I am wondering whether I can use DataContractJsonSerializer to serialize a Structure type, or does it have to be a reference/Class type?
I have the following code:
<Extension()> Public Function ToJSON(ByVal target As Object) As String
Dim serializer = New System.Runtime.Serialization.Json.DataContractJsonSerializer(target.GetType...
Hi
I am working in a highly distributed environment. A lot of network access and a lot of db access.
I have some classes that are send over and over the network , and are serialized and de-serialized.
Most of the classes are quite simple in their nature , like :
class A{
long a;
long b;
}
And some are more complex ,( Compound - C...
In .NET, I would like to call a REST-style web service which expects a POST body which is a binary serialization of a class on the following form:
public class Test
{
public string Name;
public byte[] Data;
}
The bitstream should be exactly the same as when using BinaryFormatter.Serialize(). The problem is that the Data member...
When using Scala RemoteActors I was getting a ClassNotFoundException that referred to scala.actors.remote.NetKernel. I copied someone else's example and added RemoteActor.classLoader = getClass.getClassLoader to my Actor and now everything works. Why is this necessary?
...
Please help me with this memory leak. In the leaks tool it shows a leak: NSCFString (32 bytes) in the library "Foundation" Responsible Frame: NSPropertyListSerialization. I am releasing the error but still a leak. What am I missing? Many thanks!
NSPropertyListFormat format;
NSString *anError = nil;
id plist;
plist ...
Hello,
The book Domain Driven Design by Eric Evans describes pattern called value object. One of the important characteristics of a value object is that it is immutable.
As an example I have a value object "Clinic" which must have a name and an id. To make it a value object I do not provide setters on name and id. Also to make sure th...
Hi all,
I am trying to write message to a file using serialization.Message consists of two fields-
date and TibrvMsg(TibrvMsg is a propriotory message by Tibco and this class is not serializable as per their documentation).So my custom message is:
Message msg = new Message(TibrvMsg msg).
Problem is though i m declaring Message Serializab...
I have a C# class that is serialized to disk by the BinaryFormatter, such as this example:
// Version 3.0
[Serializable]
public class Person
{
public string FullName;
[OptionalField(VersionAdded=2)]
public string NickName;
[OptionalField(VersionAdded=2)]
public DateTime BirthDate;
[OptionalField(VersionAdded=3)...
Lets say I have business class:
public class Foo
{
public int Prop1 {get;set;}
public int Prop2 {get;set;}
public Foo(int prop1, int prop2)
{
this.Prop1 = prop1;
this.Prop2 = prop2;
}
public Foo()
{
throw new NotImplementedException();
}
}
The business class is only valid if both properties a...
I'm having a remoting issue in my application. Since the architecture is quite complex, I'll try to make an simple example with dummy names to illustrate the problem.
Consider these components:
MyApp.Client.exe: client application
MyApp.Service.exe: Windows service that hosts the server
MyApp.Server.dll: server implementation
MyApp.Sh...
I'm looking for a generic way to serialize objects in Java using JAXB XML Serialization. I'd like to have something like this:
public static <T> String serializeUsingJAXB(T entity) {
JAXBContext context = JAXBContext.newInstance(T.class);
// ...
}
However, it looks as though due to type erasure, T.class doesn't work.
What wi...
If I have a web service (.asmx) and I want it to use Json.NET to serialize all the objects that I return from that web service, is there a way to do that?
In other words, I have a class like this:
[JsonObject(MemberSerialization.OptOut)]
public partial class Person
{
public string FirstName {get; set;}
publ...
What is the best strategy of making Abstract Syntax Trees serializable to an XML File?
...
I understand the theory behind incompatible serialVersionUIDs (i.e. you can discriminate different compilation versions of the same class) but I am seeing an issue that I don't understand and doesn't fall into the obvious error causes (different compiled version of the same class).
I am testing a serialization/deserialization process. A...
I've got a REST-ful WCF service that returns back an XML response. It is comprised of objects that are serializing and de-serializing correctly, with the one exception that my List property on a node is not deserializing correctly. The XML looks like:
<ShippingGroups>
<ShippingGroup>
<ShippingGroupId>
b0b4d8a4-ff1f-4f02-a47c-263ef8a...
With an object like this:
[DataContract]
public class SampleItem
{
private int _id;
[DataMember(IsRequired = true)]
public int Id
{
get { return _id; }
set { _id = value; }
}
private string _stringValue;
[DataMember()]
pu...
I'm currently using an XMLSerializer to serialize a list of a class of my own. One of the class's properties is an instance of a sealed class that does not have a parameterless constructor, so the XML Serializer refuses to serialize the class. How can I get around this? I need that property to be serialized.
Is there some way for me ...
When you new an object in C# a few things must happen:
memory for the object is created, and whatever other book-keeping CLR whats to do
fields are initialized to default values
the constructor is invoked
Serialization frameworks seem to have some magical way to do 1 without doing 2 and 3. Or maybe it's not so magical after all. How ...
Hi,
I have a class which stores data collected by the asp.net webserver. It contains several properties like:
private string _actionName;
public string ActionName
{
get
{
if (_actionName == null)
_actionName = Request.Params["action_name"] != null
? Serve...