{"orders":[{"id":41,"order_number":41,"created_at":"2016-07-21T06:34:43Z","updated_at":"2016-07-21T06:34:43Z","completed_at":"2016-07-21T06:34:43Z","status":"processing","currency":"INR","total":"25000.00","subtotal":"25000.00","total_line_items_quantity":10,"total_tax":"0.00","total_shipping":"0.00","cart_tax":"0.00","shipping_tax":"0.00","total_discount":"0.00","shipping_methods":"","payment_details":{"method_id":"cod","method_title":"Cash on Delivery","paid":false},"billing_address":{"first_name":"HARSH","last_name":"KANTHARIA","company":"ITACHI GROUP","address_1":"20 dhanlaxmi bunglows","address_2":"nr nakshatra appartment,pal","city":"surat","state":"GJ","postcode":"395009","country":"IN","email":"[email protected]","phone":"9723638788"},"shipping_address":{"first_name":"HARSH","last_name":"KANTHARIA","company":"ITACHI GROUP","address_1":"20 dhanlaxmi bunglows","address_2":"nr nakshatra appartment,pal","city":"surat","state":"GJ","postcode":"395009","country":"IN"},"note":"","customer_ip":"43.239.77.131","customer_user_agent":"Mozilla\/5.0 (Windows NT 6.1; rv:48.0) Gecko\/20100101 Firefox\/48.0","customer_id":2,"view_order_url":"http:\/\/woocommerce-5468-12693-128023.cloudwaysapps.com\/my-account\/view-order\/41","line_items":[{"id":8,"subtotal":"25000.00","subtotal_tax":"0.00","total":"25000.00","total_tax":"0.00","price":"2500.00","quantity":10,"tax_class":null,"name":"Yellow Saree","product_id":27,"sku":"","meta":[]}],"shipping_lines":[],"tax_lines":[],"fee_lines":[],"coupon_lines":[],"customer":{"id":2,"created_at":"2016-07-21T05:58:17Z","email":"[email protected]","first_name":"HARSH","last_name":"KANTHARIA","username":"harsh","role":"customer","last_order_id":"41","last_order_date":"2016-07-21T06:34:43Z","orders_count":3,"total_spent":"29600.00","avatar_url":"http:\/\/2.gravatar.com\/avatar\/?s=96","billing_address":{"first_name":"HARSH","last_name":"KANTHARIA","company":"ITACHI GROUP","address_1":"20 dhanlaxmi bunglows","address_2":"nr nakshatra appartment,pal","city":"surat","state":"GJ","postcode":"395009","country":"IN","email":"[email protected]","phone":"9723638788"},"shipping_address":{"first_name":"HARSH","last_name":"KANTHARIA","company":"ACE GROUP","address_1":"20 DHANLAXMI BUNGLOWS","address_2":"PAL","city":"SURAT","state":"GJ","postcode":"395009","country":"IN"}}},{"id":40,"order_number":40,"created_at":"2016-07-21T06:01:28Z","updated_at":"2016-07-21T06:01:28Z","completed_at":"2016-07-21T06:01:28Z","status":"processing","currency":"INR","total":"3600.00","subtotal":"3600.00","total_line_items_quantity":2,"total_tax":"0.00","total_shipping":"0.00","cart_tax":"0.00","shipping_tax":"0.00","total_discount":"0.00","shipping_methods":"","payment_details":{"method_id":"cod","method_title":"Cash on Delivery","paid":false},"billing_address":{"first_name":"HARSH","last_name":"KANTHARIA","company":"ITACHI GROUP","address_1":"20 dhanlaxmi bunglows","address_2":"nr nakshatra appartment,pal","city":"surat","state":"GJ","postcode":"395009","country":"IN","email":"[email protected]","phone":"9723638788"},"shipping_address":{"first_name":"HARSH","last_name":"KANTHARIA","company":"ITACHI GROUP","address_1":"20 dhanlaxmi bunglows","address_2":"nr nakshatra appartment,pal","city":"surat","state":"GJ","postcode":"395009","country":"IN"},"note":"","customer_ip":"43.239.77.131","customer_user_agent":"Mozilla\/5.0 (Windows NT 6.1; rv:48.0) Gecko\/20100101 Firefox\/48.0","customer_id":2,"view_order_url":"http:\/\/woocommerce-5468-12693-128023.cloudwaysapps.com\/my-account\/view-order\/40","line_items":[{"id":6,"subtotal":"2100.00","subtotal_tax":"0.00","total":"2100.00","total_tax":"0.00","price":"2100.00","quantity":1,"tax_class":null,"name":"Orange Saree","product_id":31,"sku":"","meta":[]},{"id":7,"subtotal":"1500.00","subtotal_tax":"0.00","total":"1500.00","total_tax":"0.00","price":"1500.00","quantity":1,"tax_class":null,"name":"Test product","product_id":10,"sku":"testproduct","meta":[]}],"shipping_lines":[],"tax_lines":[],"fee_lines":[],"coupon_lines":[],"customer":{"id":2,"created_at":"2016-07-21T05:58:17Z","email":"[email protected]","first_name":"HARSH","last_name":"KANTHARIA","username":"harsh","role":"customer","last_order_id":"41","last_order_date":"2016-07-21T06:34:43Z","orders_count":3,"total_spent":"29600.00","avatar_url":"http:\/\/1.gravatar.com\/avatar\/?s=96","billing_address":{"first_name":"HARSH","last_name":"KANTHARIA","company":"ITACHI GROUP","address_1":"20 dhanlaxmi bunglows","address_2":"nr nakshatra appartment,pal","city":"surat","state":"GJ","postcode":"395009","country":"IN","email":"[email protected]","phone":"9723638788"},"shipping_address":{"first_name":"HARSH","last_name":"KANTHARIA","company":"ACE GROUP","address_1":"20 DHANLAXMI BUNGLOWS","address_2":"PAL","city":"SURAT","state":"GJ","postcode":"395009","country":"IN"}}},{"id":39,"order_number":39,"created_at":"2016-07-21T05:58:17Z","updated_at":"2016-07-21T05:58:17Z","completed_at":"2016-07-21T05:58:17Z","status":"processing","currency":"INR","total":"1000.00","subtotal":"1000.00","total_line_items_quantity":1,"total_tax":"0.00","total_shipping":"0.00","cart_tax":"0.00","shipping_tax":"0.00","total_discount":"0.00","shipping_methods":"","payment_details":{"method_id":"cod","method_title":"Cash on Delivery","paid":false},"billing_address":{"first_name":"HARSH","last_name":"KANTHARIA","company":"ITACHI GROUP","address_1":"20 dhanlaxmi bunglows","address_2":"nr nakshatra appartment,pal","city":"surat","state":"GJ","postcode":"395009","country":"IN","email":"[email protected]","phone":"9723638788"},"shipping_address":{"first_name":"HARSH","last_name":"KANTHARIA","company":"ITACHI GROUP","address_1":"20 dhanlaxmi bunglows","address_2":"nr nakshatra appartment,pal","city":"surat","state":"GJ","postcode":"395009","country":"IN"},"note":"","customer_ip":"43.239.77.131","customer_user_agent":"Mozilla\/5.0 (Windows NT 6.1; rv:48.0) Gecko\/20100101 Firefox\/48.0","customer_id":2,"view_order_url":"http:\/\/woocommerce-5468-12693-128023.cloudwaysapps.com\/my-account\/view-order\/39","line_items":[{"id":5,"subtotal":"1000.00","subtotal_tax":"0.00","total":"1000.00","total_tax":"0.00","price":"1000.00","quantity":1,"tax_class":null,"name":"Test Saree product","product_id":15,"sku":"","meta":[]}],"shipping_lines":[],"tax_lines":[],"fee_lines":[],"coupon_lines":[],"customer":{"id":2,"created_at":"2016-07-21T05:58:17Z","email":"[email protected]","first_name":"HARSH","last_name":"KANTHARIA","username":"harsh","role":"customer","last_order_id":"41","last_order_date":"2016-07-21T06:34:43Z","orders_count":3,"total_spent":"29600.00","avatar_url":"http:\/\/1.gravatar.com\/avatar\/?s=96","billing_address":{"first_name":"HARSH","last_name":"KANTHARIA","company":"ITACHI GROUP","address_1":"20 dhanlaxmi bunglows","address_2":"nr nakshatra appartment,pal","city":"surat","state":"GJ","postcode":"395009","country":"IN","email":"[email protected]","phone":"9723638788"},"shipping_address":{"first_name":"HARSH","last_name":"KANTHARIA","company":"ACE GROUP","address_1":"20 DHANLAXMI BUNGLOWS","address_2":"PAL","city":"SURAT","state":"GJ","postcode":"395009","country":"IN"}}},{"id":38,"order_number":38,"created_at":"2016-07-21T05:24:29Z","updated_at":"2016-07-21T05:24:29Z","completed_at":"2016-07-21T05:24:29Z","status":"processing","currency":"INR","total":"3600.00","subtotal":"3600.00","total_line_items_quantity":2,"total_tax":"0.00","total_shipping":"0.00","cart_tax":"0.00","shipping_tax":"0.00","total_discount":"0.00","shipping_methods":"","payment_details":{"method_id":"cod","method_title":"Cash on Delivery","paid":false},"billing_address":{"first_name":"HARSH","last_name":"KANTHARIA","company":"ITACHI GROUP","address_1":"20 dhanlaxmi bunglows","address_2":"nr nakshatra appartment,pal","city":"surat","state":"GJ","postcode":"395009","country":"IN","email":"[email protected]","phone":"9723638788"},"shipping_address":{"first_name":"HARSH","last_name":"KANTHARIA","company":"ITACHI GROUP","address_1":"20 dhanlaxmi bunglows","address_2":"nr nakshatra appartment,pal","city":"surat","state":"GJ","postcode":"395009","country":"IN"},"note":"","customer_ip":"43.239.77.131","customer_user_agent":"Mozilla\/5.0 (Windows NT 6.1; rv:48.0) Gecko\/20100101 Firefox\/48.0","customer_id":0,"view_order_url":"http:\/\/woocommerce-5468-12693-128023.cloudwaysapps.com\/my-account\/view-order\/38","line_items":[{"id":4,"subtotal":"3600.00","subtotal_tax":"0.00","total":"3600.00","total_tax":"0.00","price":"1800.00","quantity":2,"tax_class":null,"name":"Black Saree","product_id":23,"sku":"DM3103","meta":[]}],"shipping_lines":[],"tax_lines":[],"fee_lines":[],"coupon_lines":[],"customer":{"id":0,"email":"[email protected]","first_name":"HARSH","last_name":"KANTHARIA","billing_address":{"first_name":"HARSH","last_name":"KANTHARIA","company":"ITACHI GROUP","address_1":"20 dhanlaxmi bunglows","address_2":"nr nakshatra appartment,pal","city":"surat","state":"GJ","postcode":"395009","country":"IN","email":"[email protected]","phone":"9723638788"},"shipping_address":{"first_name":"HARSH","last_name":"KANTHARIA","company":"ITACHI GROUP","address_1":"20 dhanlaxmi bunglows","address_2":"nr nakshatra appartment,pal","city":"surat","state":"GJ","postcode":"395009","country":"IN"}}},{"id":37,"order_number":37,"created_at":"2016-07-20T08:17:21Z","updated_at":"2016-07-20T08:17:21Z","completed_at":"2016-07-20T08:17:21Z","status":"processing","currency":"INR","total":"2100.00","subtotal":"2100.00","total_line_items_quantity":1,"total_tax":"0.00","total_shipping":"0.00","cart_tax":"0.00","shipping_tax":"0.00","total_discount":"0.00","shipping_methods":"","payment_details":{"method_id":"cod","method_title":"Cash on Delivery","paid":false},"billing_address":{"first_name":"Rahul","last_name":"Patel","company":"Resolute Solutions","address_1":"surat","address_2":"","city":"Surat","state":"GJ","postcode":"395001","country":"IN","email":"[email protected]","phone":""},"shipping_address":{"first_name":"Rahul","last_name":"Patel","company":"Resolute Solutions","address_1":"surat","address_2":"","city":"Surat","state":"GJ","postcode":"395001","country":"IN"},"note":"","customer_ip":"43.239.77.131","customer_user_agent":"Mozilla\/5.0 (Windows NT 6.3; WOW64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/51.0.2704.103 Safari\/537.36","customer_id":1,"view_order_url":"http:\/\/woocommerce-5468-12693-128023.cloudwaysapps.com\/my-account\/view-order\/37","line_items":[{"id":3,"subtotal":"2100.00","subtotal_tax":"0.00","total":"2100.00","total_tax":"0.00","price":"2100.00","quantity":1,"tax_class":null,"name":"Orange Saree","product_id":31,"sku":"","meta":[]}],"shipping_lines":[],"tax_lines":[],"fee_lines":[],"coupon_lines":[],"customer":{"id":1,"created_at":"2016-06-27T05:01:55Z","email":"[email protected]","first_name":"","last_name":"","username":"[email protected]","role":"administrator","last_order_id":"37","last_order_date":"2016-07-20T08:17:21Z","orders_count":3,"total_spent":"7300.00","avatar_url":"http:\/\/0.gravatar.com\/avatar\/?s=96","billing_address":{"first_name":"Rahul","last_name":"Patel","company":"Resolute Solutions","address_1":"surat","address_2":"","city":"Surat","state":"GJ","postcode":"395001","country":"IN","email":"[email protected]","phone":""},"shipping_address":{"first_name":"","last_name":"","company":"","address_1":"","address_2":"","city":"","state":"","postcode":"","country":""}}},{"id":35,"order_number":35,"created_at":"2016-06-27T08:09:00Z","updated_at":"2016-06-27T13:46:28Z","completed_at":"2016-06-27T13:46:28Z","status":"completed","currency":"INR","total":"4200.00","subtotal":"4200.00","total_line_items_quantity":2,"total_tax":"0.00","total_shipping":"0.00","cart_tax":"0.00","shipping_tax":"0.00","total_discount":"0.00","shipping_methods":"","payment_details":{"method_id":"cod","method_title":"Cash on Delivery","paid":false},"billing_address":{"first_name":"Rahul","last_name":"Patel","company":"Resolute Solutions","address_1":"surat","address_2":"","city":"Surat","state":"GJ","postcode":"395001","country":"IN","email":"[email protected]","phone":""},"shipping_address":{"first_name":"Rahul","last_name":"Patel","company":"Resolute Solutions","address_1":"surat","address_2":"","city":"Surat","state":"GJ","postcode":"395001","country":"IN"},"note":"","customer_ip":"43.239.77.131","customer_user_agent":"Mozilla\/5.0 (Windows NT 6.3; WOW64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/51.0.2704.103 Safari\/537.36","customer_id":1,"view_order_url":"http:\/\/woocommerce-5468-12693-128023.cloudwaysapps.com\/my-account\/view-order\/35","line_items":[{"id":2,"subtotal":"4200.00","subtotal_tax":"0.00","total":"4200.00","total_tax":"0.00","price":"2100.00","quantity":2,"tax_class":null,"name":"Orange Saree","product_id":31,"sku":"","meta":[]}],"shipping_lines":[],"tax_lines":[],"fee_lines":[],"coupon_lines":[],"customer":{"id":1,"created_at":"2016-06-27T05:01:55Z","email":"[email protected]","first_name":"","last_name":"","username":"[email protected]","role":"administrator","last_order_id":"37","last_order_date":"2016-07-20T08:17:21Z","orders_count":3,"total_spent":"7300.00","avatar_url":"http:\/\/1.gravatar.com\/avatar\/?s=96","billing_address":{"first_name":"Rahul","last_name":"Patel","company":"Resolute Solutions","address_1":"surat","address_2":"","city":"Surat","state":"GJ","postcode":"395001","country":"IN","email":"[email protected]","phone":""},"shipping_address":{"first_name":"","last_name":"","company":"","address_1":"","address_2":"","city":"","state":"","postcode":"","country":""}}},{"id":19,"order_number":19,"created_at":"2016-06-27T05:27:34Z","updated_at":"2016-06-27T05:27:34Z","completed_at":"2016-06-26T23:57:34Z","status":"processing","currency":"INR","total":"1000.00","subtotal":"1000.00","total_line_items_quantity":1,"total_tax":"0.00","total_shipping":"0.00","cart_tax":"0.00","shipping_tax":"0.00","total_discount":"0.00","shipping_methods":"","payment_details":{"method_id":"cod","method_title":"Cash on Delivery","paid":false},"billing_address":{"first_name":"Rahul","last_name":"Patel","company":"Resolute Solutions","address_1":"surat","address_2":"","city":"Surat","state":"GJ","postcode":"395001","country":"IN","email":"[email protected]","phone":""},"shipping_address":{"first_name":"Rahul","last_name":"Patel","company":"Resolute Solutions","address_1":"surat","address_2":"","city":"Surat","state":"GJ","postcode":"395001","country":"IN"},"note":"","customer_ip":"43.239.77.131","customer_user_agent":"Mozilla\/5.0 (Windows NT 6.1; WOW64; rv:44.0) Gecko\/20100101 Firefox\/44.0","customer_id":1,"view_order_url":"http:\/\/woocommerce-5468-12693-128023.cloudwaysapps.com\/my-account\/view-order\/19","line_items":[{"id":1,"subtotal":"1000.00","subtotal_tax":"0.00","total":"1000.00","total_tax":"0.00","price":"1000.00","quantity":1,"tax_class":null,"name":"Test Saree product","product_id":15,"sku":"","meta":[]}],"shipping_lines":[],"tax_lines":[],"fee_lines":[],"coupon_lines":[],"customer":{"id":1,"created_at":"2016-06-27T05:01:55Z","email":"[email protected]","first_name":"","last_name":"","username":"[email protected]","role":"administrator","last_order_id":"37","last_order_date":"2016-07-20T08:17:21Z","orders_count":3,"total_spent":"7300.00","avatar_url":"http:\/\/1.gravatar.com\/avatar\/?s=96","billing_address":{"first_name":"Rahul","last_name":"Patel","company":"Resolute Solutions","address_1":"surat","address_2":"","city":"Surat","state":"GJ","postcode":"395001","country":"IN","email":"[email protected]","phone":""},"shipping_address":{"first_name":"","last_name":"","company":"","address_1":"","address_2":"","city":"","state":"","postcode":"","country":""}}}]}
Ich bin in der Lage, diese Zeichenfolge Datentabelle zu konvertieren, aber ich bin nicht in der Lage, alle Daten zu erhalten, die innerhalb der Arrays in dem JSON-String ist, die Daten innerhalb des Arrays payment_details, billing_address, shipping_address, line_Items, shipping_lines, tax_lines, fee_lines, coupon_lines, Kunden und Arrays innerhalb des Kunden. kann mir jemand zeigen, wie man das macht. Ich brauche diese Daten für C# Windows-Anwendung. ich bin neu in diesem json Sachen so, wenn es eine Änderung in Frage fühlen sich frei zu bearbeitenWoocommerce json zu Datensatz oder Datentabelle
public static DataTable Tabulate(string json)
{
var jsonLinq = JObject.Parse(json);
// Find the first array using Linq
var srcArray = jsonLinq.Descendants().Where(d => d is JArray).First();
var trgArray = new JArray();
foreach (JObject row in srcArray.Children<JObject>())
{
var cleanRow = new JObject();
foreach (JProperty column in row.Properties())
{
// Only include JValue types
if (column.Value is JValue)
{
cleanRow.Add(column.Name, column.Value);
}
}
trgArray.Add(cleanRow);
}
return JsonConvert.DeserializeObject<DataTable>(trgArray.ToString());
}
dies ist der Code, die ich online gefunden und ich verwendet, um dieses die json zu Datatable
Bitte teilen ** die C# -Code ** Sie bereits versucht haben, die nicht funktionierten. Von https://stackoverflow.com/help/how-to-ask: * Helfen Sie anderen, das Problem zu reproduzieren ... Fügen Sie nur so viel Code ein, dass andere das Problem reproduzieren können. * Außerdem können Sie JSON vereinfachen, um ein [ mcve] deines Problems? – dbc
Ich habe den Beitrag editieren und den C# -Code eingefügt, bitte schauen Sie es sich an. Ich bin nicht in der Lage, einfach den JSON-Code Ich suchte Hilfe in diesem auch @ dbc –
Das Problem ist, dass Ihre JSON verschachtelte * Objekte * anstatt verschachtelte * Arrays von Objekten * hat, zB: '[{" id ": 41, "nested_object": {"name": "HARSH"}}] 'anstelle von' [{"id": 41, "nested_array": [{"name": "HARSH"}]}] '. Ein verschachteltes Array kann in eine verschachtelte 'DataTable' konvertiert werden, aber es gibt keine kanonische Möglichkeit, ein verschachteltes Objekt darzustellen. Was willst du dort machen? – dbc