I am trying to serialize a list to json string using Json.NET but the return string has backslash within it, which in turn is failing a json parsing.
var x = from d in entities.Books.ToList()
select new
{
ID = d.ID,
BookName = d.BookName
};
return JsonConvert.SerializeObject(x.ToList());
The above code returns
"[{"ID":1,"BookName":"MVC Music Store - Tutorial - v3.0"},{"ID":2,"BookName":"Pro.ASP.NET.MVC.3.Framework"},{"ID":3,"BookName":"Application Architecture Guide v2"},{"ID":4,"BookName":"Gang of Four Design Patterns"},{"ID":5,"BookName":"CS4 Pocket Reference"}]"
which fails all JSON parsing. How can I remove these.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…