解析这段json时报错

发布于 2022-09-04 10:29:44 字数 6963 浏览 13 评论 0

{
    "success": true,
    "errorCode": "",
    "subErrorCode": "",
    "errorDesc": "",
    "subErrorDesc": "",
    "requestMethod": "gy.erp.trade.get",
    "orders": [{
        "code": "SO57460932564",
        "qty": 2.0,
        "amount": 15.0,
        "payment": 0.0,
        "approve": false,
        "cod": false,
        "cancle": false,
        "vipIdCard": "",
        "vipEmail": "",
        "vipRealName": "常州",
        "accountStatus": "未到账",
        "accountAmount": 0.0,
        "assignState": 0,
        "platform_code": "3212511511452",
        "createtime": "2017-01-11 11:02:11",
        "modifytime": "2017-01-11 11:32:11",
        "dealtime": "2017-01-11 11:00:41",
        "paytime": null,
        "shop_name": "丽珀缇壁纸(唯一即可)",
        "shop_code": "001(唯一即可)",
        "warehouse_name": "乔松+邦",
        "warehouse_code": "888888",
        "express_name": "圆通速递",
        "express_code": "YTO",
        "vip_name": "常州常州",
        "vip_code": "CZCZ",
        "receiver_name": "常州",
        "receiver_phone": "",
        "receiver_mobile": "11111111",
        "receiver_zip": "213001",
        "receiver_address": "111111",
        "receiver_area": "江苏省-常州市-新北区",
        "buyer_memo": "",
        "seller_memo": "",
        "seller_memo_late": null,
        "post_fee": 0.0,
        "cod_fee": 0.0,
        "discount_fee": 0.0,
        "post_cost": 0.0,
        "weight_origin": 25.0,
        "payment_amount": 15.0,
        "delivery_state": 0,
        "order_type_name": null,
        "business_man": null,
        "platform_flag": 0,
        "approveDate": null,
        "accountDate": "",
        "details": [{
            "oid": null,
            "qty": 1.0,
            "price": 10.0,
            "amount": 10.0,
            "note": "",
            "item_code": "YSTEST01",
            "item_name": "手撕面包",
            "item_simple_name": "手撕面包",
            "sku_name": "手撕面包-梦之味",
            "sku_code": "YSTEST0101",
            "post_fee": 0.0,
            "discount_fee": 0.0,
            "amount_after": 0.0,
            "refund": 0,
            "platform_item_name": "",
            "platform_sku_name": ""
        }, {
            "oid": null,
            "qty": 1.0,
            "price": 5.0,
            "amount": 5.0,
            "note": "",
            "item_code": "YSTEST02",
            "item_name": "佳利佳手帕纸",
            "item_simple_name": "佳利佳手帕纸",
            "sku_name": "佳利佳手帕纸-玫瑰之恋",
            "sku_code": "YSTEST0201",
            "post_fee": 0.0,
            "discount_fee": 0.0,
            "amount_after": 0.0,
            "refund": 0,
            "platform_item_name": "",
            "platform_sku_name": ""
        }],
        "payments": [],
        "invoices": [],
        "deliverys": []
    }],
    "total": 1
}
List<GetorderModel> list=null;
try
{
    list = JsonConvert.DeserializeObject<List<GetorderModel>>(json);
}
catch (Exception ee)
{
    string mes = ee.Message;
}


public class OrderModel
{
    public string code { get; set; }
    public int qty { get; set; }
    public decimal amount { get; set; }
    public decimal payment { get; set; }
    public bool approve { get; set; }
    public bool cod { get; set; }
    public bool cancle { get; set; }
    public string vipIdCard { get; set; }
    public string vipEmail { get; set; }
    public string vipRealName { get; set; }
    public string accountStatus { get; set; }
    public double accountAmount { get; set; }
    public int assignState { get; set; }

    public string platform_code { get; set; }
    public DateTime modifytime { get; set; }
    public DateTime createtime { get; set; }
    public DateTime dealtime { get; set; }
    public DateTime paytime { get; set; }
    public string shop_name { get; set; }
    public string shop_code { get; set;}
    public string warehouse_name { get; set; }
    public string warehouse_code { get; set; }
    public string express_name { get; set; }
    public string express_code { get; set; }
    public string vip_code { get; set; }
    public string vip_name { get; set; }
    public string receiver_name { get; set; }
    public string receiver_phone { get; set; }
    public string receiver_mobile { get; set; }
    public string receiver_zip { get; set; }
    public string receiver_address { get; set; }
    public string receiver_area { get; set; }
    public string buyer_memo { get; set; }
    public string seller_memo { get; set; }
    public string seller_memo_late { get; set; }
    public decimal post_fee { get; set; }
    public decimal cod_fee { get; set; }
    public decimal discount_fee { get; set; }
    public decimal post_cost { get; set; }
    public decimal weight_origin { get; set; }
    public decimal payment_amount { get; set; }
    public int delivery_state { get; set; }
    public string order_type_name { get; set; }
    public string platform_flag { get; set; }
    public string business_man { get; set; }
    public detailsModel[] details { get; set; }
    public paymentModel paymentModel { get; set; }
    public invoicesModel invoices { get; set; }
    public deliverysModel deliverys { get; set; }

}
public class GetorderModel
{
    public string success { get; set; }
    public int total { get; set; }
    public OrderModel order { get; set; }
}
  public class deliverysModel
{
    public bool delivery { get; set; }
    public string code { get; set; }
    public bool printExpress { get; set;}
    public bool printDeliveryList { get; set; }
    public bool scan { get; set; }
    public bool weight { get; set; }
    public string warehouse_name { get; set; }
    public string warehouse_code { get; set; }
    public string express_name { get; set; }
    public string express_code { get; set; }
    public string mail_no { get; set; }
}

 public class paymentModel
{
    public double payment { get; set; }
    public string payCode { get; set; }
    public string pay_type_name { get; set; }
    public DateTime paytime { get; set; }
}

public class detailsModel
{
    public string oid { get; set; }
    public int qty { get; set; }
    public decimal price { get; set; }   
    public string note { get; set; }
    public decimal amount { get; set; }
    public int refund { get; set; }
    public string item_code { get; set; }
    public string item_name { get; set; }
    public string item_simple_name { get; set; }
    public string sku_name { get; set; }
    public string sku_code { get; set; }
    public decimal post_fee { get; set; }
    public decimal discount_fee { get; set; }
    public decimal amount_after { get; set; }
    public string platform_item_name { get; set; }
    public string platform_sku_name { get; set; }
}

 public class invoicesModel
{
    public string invoice_type_name { get; set; }
    public string invoice_title { get; set; }
    public string invoice_content { get; set; }
    public decimal invoice_amount { get; set; }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

月下客 2022-09-11 10:29:44

[] 这符号里的资料起初我都是用List<object>去接它
若是要宣告成员的话可以试试看IEnumerable<T>
try:
public class GetorderModel
{
public string success { get; set; }
public int total { get; set; }
public IEnumerable<OrderModel> order { get; set; }
}

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文