dataModel = [{"ASB_Base_1":0,"ASB_Idx_1":0,"ASB_Name_Idx_1":"non","ASB_Base_2":0,"ASB_Idx_2":0,"ASB_Name_Idx_2":"non","ASB_Base_3":0,"ASB_Idx_3":0,"ASB_Name_Idx_3":"non"},
{"ASB_Base_1":0,"ASB_Idx_1":0,"ASB_Name_Idx_1":"non","ASB_Base_2":0,"ASB_Idx_2":0,"ASB_Name_Idx_2":"non","ASB_Base_3":0,"ASB_Idx_3":0,"ASB_Name_Idx_3":"non"},
{"ASB_Base_1":0,"ASB_Idx_1":0,"ASB_Name_Idx_1":"non","ASB_Base_2":0,"ASB_Idx_2":0,"ASB_Name_Idx_2":"non","ASB_Base_3":0,"ASB_Idx_3":0,"ASB_Name_Idx_3":"non"}]
模型中的上述数据。格式与键的名称不同
public class dataModel
{
public int ASB_Base;
public int ASB_Idx;
public int ASB_Name_Idx;
}
void LoadJsonData(string jsonData)
{
List<dataModel> dataModelList = JsonConvert.DeserializeObject<List<dataModel>>(jsonData);
}
我想引入一个列表的形式,我该怎么做?请帮助!
你的类应该这样定义:
public class dataModel
{
public int ASB_Base_1 { get; set; }
public int ASB_Idx_1 { get; set; }
public string ASB_Name_Idx_1 { get; set; }
public int ASB_Base_2 { get; set; }
public int ASB_Idx_2 { get; set; }
public string ASB_Name_Idx_2 { get; set; }
public int ASB_Base_3 { get; set; }
public int ASB_Idx_3 { get; set; }
public string ASB_Name_Idx_3 { get; set; }
}