How to achieve below mentioned JSON format using C # .NET HashTable
{"DoWorkResult": [ {"Perimeter":"55}, {"Mortgage":"540"}, {"Area":"1000"} ] }
I tried to do this using a hashtable with an example as shown 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 the WCF service method, and I am using the ajax call to read the output from the backend.
Ajax method that I use in the interface:
$.ajax({ type: 'POST', url: '/Service.svc/DoWork', success: function(data) { alert(data); } });
source share