How to achieve below mentioned JSON format using C#.NET HashTable
{"DoWorkResult":
[
{"Perimeter":"55},
{"Mortgage":"540"},
{"Area":"1000"}
]
}
I tried to do this with Hashtable with an example as like below
Hashtable hashtable = new Hashtable();
hashtable.Add("Area", 1000);
hashtable.Add("Perimeter", 55);
hashtable.Add("Mortgage", 540);
But the result is as shown below
{"DoWorkResult":
[
{"Key":"Perimeter","Value":55},
{"Key":"Mortgage","Value":540},
{"Key":"Area","Value":1000}
]
}
Note : I am returning the actual Hash table in a WCF service method, and i am using an ajax call to read the output from backend.
Ajax Method i am using in front end :
$.ajax({
type: 'POST',
url: '/Service.svc/DoWork',
success: function(data) {
alert(data);
}
});
Using both JavaScriptSerializer and Json.Net