INotifyPropertyChanged
我有这个JSON数组,我想将其转换为JSON中每个属性具有"Data": [
{
"Code": "DEMO",
"Name": "DEMO",
"UserId": "B27A68AD-7C21-4DDB-8A1D-8932459CF53B",
"RoleDetails": [{
"ViewId": "B27A68AD-7C21-4DDB-8A1D-8932459CF53B",
"IsAddAllowed": true,
"IsEditAllowed": true,
"IsDeleteAllowed": true
}],
"RoleDetails1":[ {
"ViewId": "B27A68AD-7C21-4DDB-8A1D-8932459CF53B",
"IsAddAllowed": true,
"IsEditAllowed": true,
"IsDeleteAllowed": true
}]
}
]
的{{1}}。
答案 0 :(得分:0)
这是一种使用Cinchoo ETL-开源库将JSON转换为数据集的简单方法
string json = @"{
""Data"": [
{
""Code"": ""DEMO"",
""Name"": ""DEMO"",
""UserId"": ""B27A68AD-7C21-4DDB-8A1D-8932459CF53B"",
""RoleDetails"": [{
""ViewId"": ""B27A68AD-7C21-4DDB-8A1D-8932459CF53B"",
""IsAddAllowed"": true,
""IsEditAllowed"": true,
""IsDeleteAllowed"": true
}],
""RoleDetails1"":[ {
""ViewId"": ""Z27A68AD-7C21-4DDB-8A1D-8932459CF53B"",
""IsAddAllowed"": true,
""IsEditAllowed"": true,
""IsDeleteAllowed"": true
}]
}
]
}";
var dt1 = ChoJSONReader.DeserializeText(json, "$.Data[0].RoleDetails").AsDataTable();
var dt2 = ChoJSONReader.DeserializeText(json, "$.Data[0].RoleDetails1").AsDataTable();
DataSet ds = new DataSet();
ds.Tables.Add(dt1);
ds.Tables.Add(dt2);
希望有帮助。