【发布时间】:2020-05-22 12:33:16
【问题描述】:
enter image description here[ { “身份证”:2532, “父ID”:0, “数字”:“2532”, "order_key": "wc_order_FgqugoSiTCm8C", "created_via": "结帐", “版本”:“3.8.1”, “状态”:“完成”, “货币”:“新加坡元”, "date_created": "2020-05-22T07:03:19", "date_created_gmt": "2020-05-22T07:03:19", "date_modified": "2020-05-22T07:06:40", "date_modified_gmt": "2020-05-22T07:06:40", "discount_total": "0.00", "discount_tax": "0.00", "shipping_total": "42.00", "shipping_tax": "0.00", "cart_tax": "0.00", “总计”:“47.50”, "total_tax": "0.00", “prices_include_tax”:假, “客户 ID”:1, "customer_ip_address": "157.46.19.210", "customer_user_agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36", "customer_note": "", “计费”:{ "first_name": "萨拉", "last_name": "打印机测试", “公司”: ””, "address_1": "sdfgsdf", “地址2”: ””, “城市”: ””, “状态”: ””, “邮政编码”:“476456”, “国家”:“新加坡”, “电子邮件”:“ecommerce@unipro.com.sg”, “电话”:“5674645” }, “航运”: { "first_name": "萨拉", "last_name": "打印机测试", “公司”: ””, "address_1": "sdfgsdf", “地址2”: ””, “城市”: ””, “状态”: ””, “邮政编码”:“476456”, “国家”:“SG” }, "payment_method": "鳕鱼", "payment_method_title": "货到付款", "transaction_id": "", "date_paid": "2020-05-22T07:06:40", "date_paid_gmt": "2020-05-22T07:06:40", "date_completed": "2020-05-22T07:06:40", "date_completed_gmt": "2020-05-22T07:06:40", "cart_hash": "4ebf26dee924ed591c6160c0f21d7fe4", “元数据”:[ { “身份证”:42356, "key": "is_vat_exempt", “价值”:“否” } ], “line_items”:[ { “身份证”:17, “名称”:“椰子油 KERAL”, "product_id": 2511, “variation_id”:0, “数量”:1, "tax_class": "", “小计”:“4.50”, "subtotal_tax": "0.00", “总计”:“4.50”, "total_tax": "0.00", “税”:[], “元数据”:[], “sku”:“106096”, “价格”:4.5 }, { “身份证”:18, “名称”:“明星”, “product_id”:2512, “variation_id”:0, “数量”:1, "tax_class": "", “小计”:“1.00”, "subtotal_tax": "0.00", “总计”:“1.00”, "total_tax": "0.00", “税”:[], “元数据”:[], “sku”:“106081”, “价格”:1 } ], “tax_lines”:[], “运输线”:[ { “身份证”:19, "method_title": "统一费率", “method_id”:“flat_rate”, "instance_id": "20", “总计”:“42.00”, "total_tax": "0.00", “税”:[], “元数据”:[ { “身份证”:155, "key": "项目", “价值”:“椰子油 KERAL × 1,STAR × 1” } ] } ], “fee_lines”:[], “优惠券线”:[], “退款”:[], "currency_symbol": "$", “_链接”:{ “自己”: [ { "href": "https://uniprogroups.com/collegecollection/wp-json/wc/v2/orders/2532" } ], “收藏”: [ { "href": "https://uniprogroups.com/collegecollection/wp-json/wc/v2/orders" } ], “顾客”: [ { "href": "https://uniprogroups.com/collegecollection/wp-json/wc/v2/customers/1" } ] } }, { “身份证”:2527, “父ID”:0, “数字”:“2527”, "order_key": "wc_order_ru3ymWKbxuaib", "created_via": "结帐", “版本”:“3.8.1”, “状态”:“处理”, “货币”:“新加坡元”, "date_created": "2020-05-22T04:32:25", "date_created_gmt": "2020-05-22T04:32:25", "date_modified": "2020-05-22T04:32:25", "date_modified_gmt": "2020-05-22T04:32:25", "discount_total": "0.00", "discount_tax": "0.00", "shipping_total": "42.00", "shipping_tax": "0.00", "cart_tax": "0.00", “总计”:“44.50”, "total_tax": "0.00", “prices_include_tax”:假, “客户 ID”:1, "customer_ip_address": "157.46.19.210", "customer_user_agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36", "customer_note": "", “计费”:{ "first_name": "萨拉", "last_name": "打印机测试", “公司”: ””, "address_1": "sdfgsdf", “地址2”: ””, “城市”: ””, “状态”: ””, “邮政编码”:“476456”, “国家”:“新加坡”, “电子邮件”:“ecommerce@unipro.com.sg”, “电话”:“5674645” }, “航运”: { "first_name": "萨拉", "last_name": "打印机测试", “公司”: ””, "address_1": "sdfgsdf", “地址2”: ””, “城市”: ””, “状态”: ””, “邮政编码”:“476456”, “国家”:“SG” }, "payment_method": "鳕鱼", "payment_method_title": "货到付款", "transaction_id": "", “日期支付”:空, “date_paid_gmt”:空, “日期完成”:空, “date_completed_gmt”:空, "cart_hash": "932d91bdbf989a4c8c3ea868474dfed8", “元数据”:[ { “身份证”:42316, "key": "is_vat_exempt", “价值”:“否” } ], “line_items”:[ { “身份证”:14, “名称”:“AMBI 1100”, “product_id”:2514, “variation_id”:0, “数量”:1, "tax_class": "", “小计”:“0.00”, "subtotal_tax": "0.00", “总计”:“0.00”, "total_tax": "0.00", “税”:[], “元数据”:[], “sku”:“106015”, “价格”:0 }, { “身份证”:15, "name": "GRB GASOGOLLA", “product_id”:2515, “variation_id”:0, “数量”:1, "tax_class": "", “小计”:“2.50”, "subtotal_tax": "0.00", “总计”:“2.50”, "total_tax": "0.00", “税”:[], “元数据”:[], “sku”:“106014”, “价格”:2.5 } ], “tax_lines”:[], “运输线”:[ { “身份证”:16, "method_title": "统一费率", “method_id”:“flat_rate”, "instance_id": "20", “总计”:“42.00”, "total_tax": "0.00", “税”:[], “元数据”:[ { “身份证”:131, "key": "项目", “价值”:“AMBI 1100 × 1,GRB GASOGOLLA × 1” } ] } ], “fee_lines”:[], “优惠券线”:[], “退款”:[], "currency_symbol": "$", “_链接”:{ “自己”: [ { "href": "https://uniprogroups.com/collegecollection/wp-json/wc/v2/orders/2527" } ], “收藏”: [ { "href": "https://uniprogroups.com/collegecollection/wp-json/wc/v2/orders" } ], “顾客”: [ { "href": "https://uniprogroups.com/collegecollection/wp-json/wc/v2/customers/1" } ] } } ]
【问题讨论】:
-
到目前为止你尝试了什么?
-
我试过了,但是出错了
-
Newtonsoft.Json.JsonSerializationException: '无法将当前 JSON 数组(例如 [1,2,3])反序列化为类型 '_Model.orderClass+oderlist',因为该类型需要 JSON 对象(例如 { "name":"value"}) 以正确反序列化。要修复此错误,请将 JSON 更改为 JSON 对象(例如 {"name":"value"})或将反序列化类型更改为数组或实现集合接口的类型(例如 ICollection、IList),例如 List
可以从 JSON 数组反序列化。 JsonArrayAttribute 也可以添加到类型中,以强制它从 JSON 数组中反序列化。 -
如果您要添加代码,我们可以为您提供更具体的反馈,但错误消息非常明确:您正在尝试将对象列表反序列化为单个对象。修改你的反序列化调用,它应该类似于这个例子
JsonConvert.DeserializeObject<List<Customer>>(json);。 -
是的!谢谢它的工作