少发了个类
    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; }
    }

解决方案 »

  1.   

    哥,好好的一段json,你加注释干嘛?
      

  2.   

      把Freight类标记成可序列化   标记[Serializable],试试。把你所有被序列化的类都加上
      

  3.   

    我这里没有问题啊。是不是你的txt文件的encoding出问题了?
      

  4.   

    类名前加上[Serializable]属性名前加上[DataMember]
    [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; }
    }
      

  5.   

    个人习惯而已,和表名称有关额,你那里没问题吗?可以正常的反序列化成对象Freight吗?我这里肿么总是报错额!你用的是我提供的那串json字符串吗?
    可以麻烦你把你的测试代码贴给我看下吗?不胜感激!
      

  6.   

    设置了,也还是一样!不得不说一句CSDN真蛋疼,加载个评论框老半天都加载不了,真晕!
      

  7.   

    代码没有动过,只是在vs中新建一个文件,把你的字符串都copy进去,再读取。VS2012, .net framework4  winform project.
           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; }
        }
      

  8.   


    恩 试了javaScriptSerializer可以,只是想知道为什么DataContractJsonSerializer不行,我在研究看看!
      

  9.   


        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;
        }
    把特殊字符替换掉试试看