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.

Leave a Comment