c# - 解析这段json时报错

查看:136
本文介绍了c# - 解析这段json时报错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

{
    "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; }
}

解决方案

http://www.aichengxu.com/view...

这篇关于c# - 解析这段json时报错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆