Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Json.Net And ActionResult

Tags:

Im building a JObject myself and want to return it as ActionResult. I dont want to create and then serialize a data object

For example

public ActionResult Test(string id) {       var res = new JObject();       JArray array = new JArray();       array.Add("Manual text");       array.Add(new DateTime(2000, 5, 23));       res["id"] = 1;       res["result"] = array;       return Json(res); //??????? } 
like image 352
NeatNerd Avatar asked Feb 21 '14 15:02

NeatNerd


1 Answers

You should just be able to do this in your action method:

return Content( res.ToString(), "application/json" ); 
like image 96
Craig W. Avatar answered Sep 22 '22 23:09

Craig W.