引用 Newtonsoft.Json.dll
1、json字符串
string xxx = "{\"count\":\"1\",\"Product_Code\":\"14003949\",\"Product_Name\":\"聚丙烯树脂\",\"Product_Batch\":\"20140228D8103\",\"Certification_Code\":\"SCSH20140226-001-01\",\"Plate_Code\":\"L5E-89\",\"Grade\":\"合格品\",\"WarehouseIn_Num\":\"19120.0000000\",\"WarehouseIn_Weight\":\"478.000\",\"WarehouseIn_Confirm_Date\":\"2014-03-01\"}";
则直接转换为对象:
M_WarehouseInResult whh = JsonConvert.DeserializeObject<M_WarehouseInResult>(xxx);
2、如果为json数组(注意:最外是中括号)
string xxx = "[{\"count\":\"1\",\"Product_Code\":\"14003949\",\"Product_Name\":\"聚丙烯树脂\",\"Product_Batch\":\"20140228D8103\",\"Certification_Code\":\"SCSH20140226-001-01\",\"Plate_Code\":\"L5E-89\",\"Grade\":\"合格品\",\"WarehouseIn_Num\":\"19120.0000000\",\"WarehouseIn_Weight\":\"478.000\",\"WarehouseIn_Confirm_Date\":\"2014-03-01\"}]";
json数组转换为list
附:
public class M_WarehouseInResult
{
public string count { get; set; }
public string Product_Code { get; set; }
public string Product_Name { get; set; }
public string Product_Batch { get; set; }
public string Certification_Code { get; set; }
public string Plate_Code { get; set; }
public string Grade { get; set; }
public string WarehouseIn_Num { get; set; }
public string WarehouseIn_Weight { get; set; }
public string WarehouseIn_Confirm_Date { get; set; }
}