jion输出字符中的引号转换问题
请教一个低级问题。
List<string> treenodes = new List<string>();
DataTable dt = city.ListToDataTable();
DataView dvRootNodes = new DataView(dt);
dvRootNodes.RowFilter = "rootID=0";
foreach (DataRowView dv in dt.DefaultView)
{
string node = string.Format("{{ \"CityID\":{0}, \"RootID\":{1}, \"CityName\":\"{2}\",\"url\":\"http://www.baidu.com\",\"isParent\":true}}",
dv["CityID"],dv["RootID"],dv["CityName"]);
treenodes.Add( node);
}
string strs = string.Join(",", treenodes.ToArray());
strs在前台显示为
{"CityID":1, "RootID":0, "CityName":"北京市","url":"http://www.baidu.com","isParent":true}
要怎么写,才能使页面显示的时候这段代码显示正常
{"CityID":1,"RootID":0,"CityName":"北京市","url":"","isParent":true}
我这是在使用ztree控件的时候。出现的问题。
------解决方案--------------------string strs = HttpUtility.HtmlDecode(string.Join(",", treenodes.ToArray()));
------解决方案--------------------var treeNodes = [<%: ViewData["NodesData"] %>];
treeNodes=treeNodes.replace(""",'"');
------解决方案--------------------
var treeNodes = [<%=HttpUtility.HtmlDecode(ViewData["NodesData"].ToString()) %>];