下载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);
}
}
}
}
}
}