Сложные преобразования JSON в объект DataTable в C#
Привет,
PFA ниже json преобразуется в datatable в c#.
Пожалуйста, помогите мне срочно.
{"TotalPurchaseOrders":1,"PurchaseOrders":[{"RN":"16872","OD":"2017-12-25T13:41:51.637","RD":"2017-12-25T13:41:53.693","Status":"UPDATED","CD":null,"VC":"BIWL","VN":"LLPL Bhiwandi Depot","CST#":"","TIN#":"","InvNum":"","Partials":[{"DD":null,"DV":0.0,"SAH":0.0,"Other":0.0,"InvNum":"","Notes":"","Items":[{"PC":"TGFB100","HSN":"3305.10.90","PN":"TIGI SF SERIOUS COND 750ML","MRP":3000.0,"RQO":0,"CQO":1,"UPO":1992.14,"OTB":[{"TC":"SGST/UTGST 14%","TA":278.9000},{"TC":"CGST 14%","TA":278.9000}],"OTN":"SGST 28%","OT":557.8,"RQD":0,"CQD":1,"UPD":1992.14,"DTD":0,"DVD":0.0,"DT":557.8,"DTB":[{"TC":"SGST/UTGST 14%","TA":278.9000},{"TC":"CGST 14%","TA":278.9000}],"DTN":"SGST 28%","Notes":""}]}]}],
"Ошибка":null}
Что я уже пробовал:
// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do: // // using QuickType; // // var data = Welcome.FromJson(jsonString); namespace QuickType { using System; using System.Net; using System.Collections.Generic; using Newtonsoft.Json; public partial class Root { [JsonProperty("TotalPurchaseOrders")] public long TotalPurchaseOrders { get; set; } [JsonProperty("PurchaseOrders")] public PurchaseOrder[] PurchaseOrders { get; set; } [JsonProperty("Error")] public object Error { get; set; } } public partial class PurchaseOrder { [JsonProperty("RN")] public string Rn { get; set; } [JsonProperty("OD")] public System.DateTime Od { get; set; } [JsonProperty("RD")] public System.DateTime Rd { get; set; } [JsonProperty("Status")] public string Status { get; set; } [JsonProperty("CD")] public object Cd { get; set; } [JsonProperty("VC")] public string Vc { get; set; } [JsonProperty("VN")] public string Vn { get; set; } [JsonProperty("CST#")] public string Cst { get; set; } [JsonProperty("TIN#")] public string Tin { get; set; } [JsonProperty("InvNum")] public string InvNum { get; set; } [JsonProperty("Partials")] public Partial[] Partials { get; set; } } public partial class Partial { [JsonProperty("DD")] public object Dd { get; set; } [JsonProperty("DV")] public long Dv { get; set; } [JsonProperty("SAH")] public long Sah { get; set; } [JsonProperty("Other")] public long Other { get; set; } [JsonProperty("InvNum")] public string InvNum { get; set; } [JsonProperty("Notes")] public string Notes { get; set; } [JsonProperty("Items")] public Item[] Items { get; set; } } public partial class Item { [JsonProperty("PC")] public string Pc { get; set; } [JsonProperty("HSN")] public string Hsn { get; set; } [JsonProperty("PN")] public string Pn { get; set; } [JsonProperty("MRP")] public long Mrp { get; set; } [JsonProperty("RQO")] public long Rqo { get; set; } [JsonProperty("CQO")] public long Cqo { get; set; } [JsonProperty("UPO")] public double Upo { get; set; } [JsonProperty("OTB")] public Dtb[] Otb { get; set; } [JsonProperty("OTN")] public string Otn { get; set; } [JsonProperty("OT")] public double Ot { get; set; } [JsonProperty("RQD")] public long Rqd { get; set; } [JsonProperty("CQD")] public long Cqd { get; set; } [JsonProperty("UPD")] public double Upd { get; set; } [JsonProperty("DTD")] public long Dtd { get; set; } [JsonProperty("DVD")] public long Dvd { get; set; } [JsonProperty("DT")] public double Dt { get; set; } [JsonProperty("DTB")] public Dtb[] Dtb { get; set; } [JsonProperty("DTN")] public string Dtn { get; set; } [JsonProperty("Notes")] public string Notes { get; set; } } public partial class Dtb { [JsonProperty("TC")] public string Tc { get; set; } [JsonProperty("TA")] public double Ta { get; set; } } public partial class Root { public static Root FromJson(string json) { return JsonConvert.DeserializeObject<Root>(json); } } public static class Serialize { public static string ToJson(this Root self) { return JsonConvert.SerializeObject(self); //return JsonConvert.SerializeObject(self, Converter.Settings); } } //public class Converter //{ // public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings // { // MetadataPropertyHandling = MetadataPropertyHandling.Ignore, // DateParseHandling = DateParseHandling.None, // }; //} }
CPallini
И в чем же ваша проблема?