I have the following data as a string in the Action method:
string json = "[[1,2],[3,4],[5,6]]";
Simple
When I call the Json view, it encapsulates the result in two double quotes. This stops the client side javascript from loading this result into the javascript object.
eg.
return Json(json);
result => "[[1,2],[3,4],[5,6]]"
but if I return the result as ContentResult, the result will be loaded into the javascript object, and I can do everything I need with it.
eg.
return new ContentResult
{
Content = json,
ContentType = "application/json",
ContentEncoding =System.Text.Encoding.UTF8
};
result => [[1,2],[3,4],[5,6]]
(notice how the double quotes are missing?).
So, can someone explain what I should do right, please? I feel ContentResult is the wrong way to do this.
source
share