Return Json, but it includes backward slashes "\", which I don't want

I had the same issue, until just a few moments ago. Turns out that I was "double serializing" the JSON string. I use a jQuery $.getJson( AJAX call to a JsonResult controller action. And because the action builds a C# Generic List<t> I thought that I had to use JSON.net/NewtonSoft to convert the C# Generic List<t> to a JSON object before returning the JSON using the following:

return Json(fake, JsonRequestBehavior.AllowGet);

I didn't have to use the JsonConvert.SerializeObject( method after all, evidently this return will conver the serialization for us.

Hope it helps you or someone else too.


i found the solution here it is

return new HttpResponseMessage() 
{
    Content = new StringContent(json, System.Text.Encoding.UTF8, "application/json")
};

using Newtonsoft.Json.Linq;
string str = "Your String with Back Slashes";
str = JToken.Parse(str).ToString(); `// Now You will get the Normal String with "NO SLASHES"`