So i have httpget request, that should return a datatable
from my database. I convert my datatable into EnumerableRowCollection
,then serialize it into json string (using json.net):
public string GetResult(DataTable dt)
{
EnumerableRowCollection Result = from row in dt.AsEnumerable()
select new
{
account = (string)row["ACCOUNT_ID"],
balance = (decimal)row["BALANCE"]
};
string json = JsonConvert.SerializeObject(Result, Formatting.None);
return json;
}
And then i pass it to the controller.
It's ok - except one thing - controller itself is serializing the request and i get a double serialized json string with back slashes (here is a part of a json):
[{\"account\":\"121\",\"balance\":-348}]
I can't figure out how else can i pass the EnumerableRowCollection
(not using a json string), so that i wont get a double serialized json? (or maybe i shouldnt convert it to a EnumerableRowCollection
at all?)