{\"ErrorCode\":0,\"Success\":true,\"ErrMessage\":\"数据源ID:4418,错误:\",\"HasData\":true,\"Records\":[{\"Time\":\"2012-03-08 16:31:00\",\"Location\":\"中环路东二路路口\",\"Reason\":\"机动车通过有灯控路口时,不按所需行进方向驶入导向车道的\",\"count\":\"100\",\"status\":\"\",\"department\":\"\",\"Degree\":\"0\",\"Code\":\"1208\",\"Archive\":\"4401261001227283\",\"Telephone\":\"\",\"Excutelocation\":\"\",\"Excutedepartment\":\"\",\"Category\":\"\",\"Latefine\":\"\",\"Punishmentaccording\":\"\",\"Illegalentry\":\"\",\"Locationid\":4401,\"DataSourceID\":4401,\"RecordType\":\"实时数据\",\"Other\":\"\"},{\"Time\":\"2012-02-24 19:09:00\",\"Location\":\"番禺大道龙美高架桥甘棠村段\",\"Reason\":\"机动车行驶超过规定时速50%以下的\",\"count\":\"150\",\"status\":\"\",\"department\":\"\",\"Degree\":\"3\",\"Code\":\"1303\",\"Archive\":\"4401261001053350\",\"Telephone\":\"\",\"Excutelocation\":\"\",\"Excutedepartment\":\"\",\"Category\":\"\",\"Latefine\":\"\",\"Punishmentaccording\":\"\",\"Illegalentry\":\"\",\"Locationid\":4401,\"DataSourceID\":4401,\"RecordType\":\"实时数据\",\"Other\":\"\"},{\"Time\":\"2012-01-06 09:39:00\",\"Location\":\"莞佛高速\",\"Reason\":\"在高速公路上超速不足50%的\",\"count\":\"200\",\"status\":\"\",\"department\":\"\",\"Degree\":\"3\",\"Code\":\"4305\",\"Archive\":\"4401131000268873\",\"Telephone\":\"\",\"Excutelocation\":\"\",\"Excutedepartment\":\"\",\"Category\":\"\",\"Latefine\":\"\",\"Punishmentaccording\":\"\",\"Illegalentry\":\"\",\"Locationid\":4401,\"DataSourceID\":4401,\"RecordType\":\"实时数据\",\"Other\":\"\"},{\"Time\":\"2011-12-31 11:08:00\",\"Location\":\"天科路路段\",\"Reason\":\"机动车违反禁止标线指示的\",\"count\":\"200\",\"status\":\"\",\"department\":\"\",\"Degree\":\"3\",\"Code\":\"1345\",\"Archive\":\"4401131000192363\",\"Telephone\":\"\",\"Excutelocation\":\"\",\"Excutedepartment\":\"\",\"Category\":\"\",\"Latefine\":\"\",\"Punishmentaccording\":\"\",\"Illegalentry\":\"\",\"Locationid\":4401,\"DataSourceID\":4401,\"RecordType\":\"实时数据\",\"Other\":\"\"},{\"Time\":\"2011-10-15 09:20:00\",\"Location\":\"华粤街路口\",\"Reason\":\"机动车违反规定停放、临时停车,妨碍其它车辆、行人通行的\",\"count\":\"200\",\"status\":\"\",\"department\":\"\",\"Degree\":\"0\",\"Code\":\"1039\",\"Archive\":\"4401131009159332\",\"Telephone\":\"\",\"Excutelocation\":\"\",\"Excutedepartment\":\"\",\"Category\":\"\",\"Latefine\":\"\",\"Punishmentaccording\":\"\",\"Illegalentry\":\"\",\"Locationid\":4401,\"DataSourceID\":4401,\"RecordType\":\"实时数据\",\"Other\":\"\"},{\"Time\":\"2011-07-03 08:12:00\",\"Location\":\"黄埔大道\",\"Reason\":\"机动车违反禁止标线指示的\",\"count\":\"200\",\"status\":\"\",\"department\":\"\",\"Degree\":\"3\",\"Code\":\"1345\",\"Archive\":\"4401131008101821\",\"Telephone\":\"\",\"Excutelocation\":\"\",\"Excutedepartment\":\"\",\"Category\":\"\",\"Latefine\":\"\",\"Punishmentaccording\":\"\",\"Illegalentry\":\"\",\"Locationid\":4401,\"DataSourceID\":4401,\"RecordType\":\"实时数据\",\"Other\":\"\"},{\"Time\":\"2011-06-26 13:03:00\",\"Location\":\"华就路\",\"Reason\":\"机动车违反规定停放、临时停车,妨碍其它车辆、行人通行的\",\"count\":\"200\",\"status\":\"\",\"department\":\"\",\"Degree\":\"0\",\"Code\":\"1039\",\"Archive\":\"4401131008033417\",\"Telephone\":\"\",\"Excutelocation\":\"\",\"Excutedepartment\":\"\",\"Category\":\"\",\"Latefine\":\"\",\"Punishmentaccording\":\"\",\"Illegalentry\":\"\",\"Locationid\":4401,\"DataSourceID\":4401,\"RecordType\":\"实时数据\",\"Other\":\"\"}],\"Other\":null,\"ResultType\":\"实时数据\",\"LastSearchTime\":null}
在.ashx文件里怎么把"\"去掉,或者怎样把'换成""
爲什麽去掉呢?這個是正常的 josn 數據哦。
反序列化不成功呀JsonConvert.DeserializeObject(),用它不行呀。
@wlz0815:
//将Json字符串转化成对象
DataContractJsonSerializer outDs =
new
DataContractJsonSerializer(
typeof
(Person));
using
(MemoryStream outMs =
new
MemoryStream(Encoding.UTF8.GetBytes(output)))
{
Person outPerson = outDs.ReadObject(outMs)
as
Person;
Console.WriteLine(
"ID:"
+ outPerson.ID);
Console.WriteLine(
"Name:"
+ outPerson.Name);
Console.WriteLine(
"Age:"
+ outPerson.Age);
Console.WriteLine(
"Birthday:"
+ outPerson.BirthDay);
}
@無限遐想: 辛苦了。。
josn 数据的格式···javascript 来读没问题的· 你可以反序列化下 就去掉了
怎样写,能说具体点不,试了好久都不行,还请赐教,不慎感激。
嗯,谢谢,我已经解决了。
可以用正则表达式进行替换:
Regex.Replace(text, @"(?<=[{,])(\\"")|(\\"")(?=[:}])", @"""")
谢谢,我已经解决了。
/// <summary>
/// 生成Joson字符串
/// </summary>
/// <param name="ti">ti</param>
/// <returns></returns>
public string ToJonsonString(List<TreeItem> ti)
{
JavaScriptSerializer jss = new JavaScriptSerializer();
string sJson = jss.Serialize(ti);
return "var treedata=" + sJson + ";";
}
谢谢,解决了。