wendi_0506的专栏

专注于互联网研究

c# json格式循环处理
下载System.Web.Script.Serialization.dll
先引用using System.Web.Script.Serialization;
StreamReader read = new StreamReader("12345.txt");
                string str = read.ReadToEnd();
                JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
                ArrayList arrayList = javaScriptSerializer.Deserialize<ArrayList>(str);
                string year = string.Empty;
                string make = string.Empty;
                string model = string.Empty;
                if (arrayList.Count > 0)
                {
                    foreach (Dictionary<string, object> dictionary in arrayList)
                    {
                        foreach (string current in dictionary.Keys)
                        {
                            object s = dictionary[current];
                            if (current == "y")//年份
                            {
                                year = s.ToString();
                            }
                            else if (current == "d")
                            {
                                Dictionary<string, object> sdic = (Dictionary<string, object>)s;
                                foreach (string mk in sdic.Keys)
                                {
                                    make = mk;
                                    object mod = sdic[mk];
                                    ArrayList mddic = (ArrayList)mod;
                                    foreach (object md in mddic)
                                    {
                                        model = md.ToString();
                                        int obj = DBUtility.SqlHelper.ExecuteNonQuery(Conn, CommandType.Text, "insert into ebaymodel(year,make,model) values(" + year + ",'" + make + "','" + model + "')");
                                        if (obj > 0)
                                        {
                                            this.LB.BeginInvoke(new showMsgDelegate(showMsg), string.Format("year{0}--make{1}--model{2}", year, make, model));
                                        }
                                        Thread.Sleep(10);
                                    }
                                }
                            }
                        }

                    }
                }

阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。联系QQ:1254584012 https://blog.csdn.net/wendi_0506/article/details/17095183
个人分类: 代码
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

c# json格式循环处理

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭