How to get a JSON object from a DataContract .NET with dynamic names

254 Views Asked by At

I have the following object:

[DataContract]
public class A
{
   [DataMember]
   Dictionary<string,string> B {get; set;}
} 

With the default serialization using DataContractJsonSerializer I get the following JSON

{ B : [{"Key":"Rable","Value":"RableRable"}] }

But what I want to get is the following

{ B : [ { "Rable" : "RableRable" } ] }

being the "Rable" the key of an Dictionary Entry and the "RableRable" the value.

0

There are 0 best solutions below