少发了个类
public class Freight_List
{
public int FID { get; set; }
public string FLName { get; set; }
public string FLCityID { get; set; }
public string FLProvinceID { get; set; }
public int FLFirstNumber { get; set; }
public decimal FLFirstMoney { get; set; }
public int FLAddNumber { get; set; }
public decimal FLAddMoney { get; set; }
}
public class Freight_List
{
public int FID { get; set; }
public string FLName { get; set; }
public string FLCityID { get; set; }
public string FLProvinceID { get; set; }
public int FLFirstNumber { get; set; }
public decimal FLFirstMoney { get; set; }
public int FLAddNumber { get; set; }
public decimal FLAddMoney { get; set; }
}
解决方案 »
- 在gridview中实现行的上移下移,如果在数据表中添加一个专门排序列SortID (int),这样就可以改变数据库中
- 新手
- asp--convert to--asp.net的烦恼!!
- 如何在TreeView后面加两个按钮,指向不同的URL
- MVC二级联动,数据从数据库读取
- (急........)菜鸟第一次在CSDN发帖,0分求教各位大侠一.NET问题.
- asp.net网站后台执行编辑操作时候异常,求解决办法
- 请问如何在ASP.NET中实现例似于JavaScript中alert和prompt的函数功能?
- 请教有关取得字符长度的问题
- 高分求教 有关datagrid中超级连接列的问题
- asp.net邮件发送
- JQuery调用WebService中的方法,返回DataSet,里面字段的值获取不到,该如何解决?
[Serializable]
public class ProgramInfo
{
public ProgramInfo()
{
} public ProgramInfo(DataRow row)
{
_prog_id = Convert.ToInt32(row["prog_id"]);
_prog_name = Convert.ToString(row["prog_name"]);
if (row["prog_desc"] != DBNull.Value) _prog_desc = Convert.ToString(row["prog_desc"]);
if (row["parent_prog_id"] != DBNull.Value) _parent_prog_id = Convert.ToInt32(row["parent_prog_id"]);
if (row["url"] != DBNull.Value) _url = Convert.ToString(row["url"]);
if (row["image_url"] != DBNull.Value) _image_url = Convert.ToString(row["image_url"]);
_enabled = Convert.ToBoolean(row["enabled"]);
if (row["category"] != DBNull.Value) _category = Convert.ToInt32(row["category"]);
if (row["rmks"] != DBNull.Value) _rmks = Convert.ToString(row["rmks"]);
} private int _prog_id;
[DataMember]
public int prog_id
{
get { return _prog_id; }
set { _prog_id = value; }
} private string _prog_name;
[DataMember]
public string prog_name
{
get { return _prog_name; }
set { _prog_name = value; }
}
可以麻烦你把你的测试代码贴给我看下吗?不胜感激!
private void button1_Click(object sender, EventArgs e)
{
string str = File.ReadAllText(@"Json.txt", Encoding.GetEncoding("gb2312"));
DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Freight));
MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(str));
Freight obj = ser.ReadObject(ms) as Freight;
Console.WriteLine(obj.FName);
Console.ReadLine();
}
。 public class Freight
{
public int FID { get; set; } public string FName { get; set; } public int FProvince { get; set; }
public string FProvinceName { get; set; } public int FCity { get; set; }
public string FCityName { get; set; } public int FArea { get; set; }
public string FAreaName { get; set; } public int FIsPostage { get; set; } public int FValuation { get; set; } public int FSendType { get; set; } public int FDefaultNumber { get; set; } public decimal FDefaultMoney { get; set; } public int FDefaultAddNumber { get; set; } public decimal FDefaultAddMoney { get; set; }
public IList<Freight_List> Freight_List { get; set; }
} public class Freight_List
{
public int FID { get; set; }
public string FLName { get; set; }
public string FLCityID { get; set; }
public string FLProvinceID { get; set; }
public int FLFirstNumber { get; set; }
public decimal FLFirstMoney { get; set; }
public int FLAddNumber { get; set; }
public decimal FLAddMoney { get; set; }
}
恩 试了javaScriptSerializer可以,只是想知道为什么DataContractJsonSerializer不行,我在研究看看!
private static string Repalce(string str)
{
str = System.Text.RegularExpressions.Regex.Replace(str, @"<", "lt;");
str = System.Text.RegularExpressions.Regex.Replace(str, @">", "gt;");
str = System.Text.RegularExpressions.Regex.Replace(str, @"\\", "quot;");
str = System.Text.RegularExpressions.Regex.Replace(str, @"\r", "");
str = System.Text.RegularExpressions.Regex.Replace(str, @"\n", "");
return str;
}
把特殊字符替换掉试试看