I am converting C# list into JSON using JSON.NET library. After converting the object when I look into quick watch I can see extra '\' with every property. I am sending this data via a controller (asp.net MVC controller) to one of JavaScript client. When the data is sent, data is having extra '\'. How can I remove these extra '\'?
my controller:
public class MyController : myBase
{
public string Get(string id = null, string userName = null)
{
List<Data> dataList = new List<Data>();
Data d = new Data();
d.Name = "FireFox";
d.Folder = @"Testing\Mac OSX";
dataList.Add(d);
d = new Data();
d.Name = "Safari";
d.Folder = @"Testing\Mac OSX";
dataList.Add(d);
d = new Data();
d.Name = "Chrome";
d.Folder = @"Testing\Mac OSX";
dataList.Add(d);
d = new Data();
d.Name = "FireFox";
d.Folder = @"Testing\Windows";
dataList.Add(d);
d = new Data();
d.Name = "Safari";
d.Folder = @"Testing\Windows";
dataList.Add(d);
d = new Data();
d.Name = "Chrome";
d.Folder = @"Testing\Windows";
dataList.Add(d);
d = new Data();
d.Name = "Internet Exploder";
d.Folder = @"Testing\Windows";
dataList.Add(d);
d = new Data();
d.Name = "Chrome";
d.Folder = @"Testing\Linux";
dataList.Add(d);
d = new Data();
d.Name = "Firefox";
d.Folder = @"Testing\Linux";
dataList.Add(d);
d = new Data();
d.Name = "Testing First Child";
d.Folder = @"Testing";
dataList.Add(d);
d = new Data();
d.Name = "First Child";
d.Folder = null;
dataList.Add(d);
Node root = new Node();
foreach (Data da in dataList)
{
Node parent = root;
if (!string.IsNullOrEmpty(da.Folder))
{
Node child = null;
foreach (string part in da.Folder.Split(new char[] {'\\'}, StringSplitOptions.RemoveEmptyEntries))
{
string name = part.Trim();
child = parent.children.Find(n => n.Name == name);
if (child == null)
{
child = new Node {Name = name};
parent.children.Add(child);
}
parent = child;
}
}
//Always adds the leaf node.
parent.children.Add(new Node {Name = da.Name});
}
string output = JsonConvert.SerializeObject(root);
return output;
}
}
public class Data
{
public string Name { get; set; }
public string Folder { get; set; }
}
class Node
{
public Node()
{
children = new List<Node>();
}
public List<Node> children { get; set; }
public string Name { get; set; }
public bool leaf { get; set; }
public bool expanded { get; set; }
}
data in firefox --- other controllers are returning data without '\'

Extra '\'

How can i remove these '\' ?