我有一个带有多个Json对象的Json字符串。我想知道如何将Json字符串反序列化为DataSet
我已经将Json字符串反序列化为DataTable。它可以正常工作,但我想知道如何将多个json对象转换为数据集
public static DataTable JsonToDataTable(string StrController)
{
DataTable Table = new DataTable();
using (var httpClient1 = new HttpClient())
{
httpClient1.BaseAddress = new Uri("http://laravel.kharind.com:90/");
httpClient1.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage response = httpClient1.GetAsync("api/"+StrController).Result;
if (response.IsSuccessStatusCode)
{
var message = response.Content.ReadAsStringAsync().Result;
Table = (DataTable)JsonConvert.DeserializeObject(message,(typeof(DataTable)));
}
}
return Table;
}
Json字符串:-
{
"Header":[
{
"GatePassHeaderId":"15683",
"GatePassNo":"LI/19/0074",
"GatePassDate":"2019-10-10 00:00:00",
"GatePassType":null,
"ToName":"Hoggo Boss",
"SupplierId":"397",
"PreparedBy":"Anwarullah",
"AuthorizedBy":"Asraar Ahmed",
"ReceivedBy":"By Van",
"DespatchMode":"Blue Dart Courier",
"VehicleNo":"TN-20 CW 9420",
"Value":null,
"Remarks":"test",
"Remarks2":"4",
"IsReturnable":"1",
"ReceivedInGate":"0",
"Closed":null,
"PrintTime":null,
"AirwayBillNo":null,
"Approved":null,
"WithoutApproved":null,
"CreatedUserId":"0",
"CreatedDateTime":"2019-10-10 09:47:00",
"SystemUserId":"ismail",
"LastModifiedUserId":null,
"LastModifiedDateTime":null
}
],
"Details":[
{
"JobWorkDetailsId":"32",
"MaterialId":"13476",
"Quantity":"44.00",
"CGST":"5.00",
"SGST":"5.00",
"IGST":"5.00",
"Rate":"56.00"
},
{
"JobWorkDetailsId":"33",
"MaterialId":"13519",
"Quantity":"55.00",
"CGST":"7.00",
"SGST":"7.00",
"IGST":"7.00",
"Rate":"67.00"
}
]
}