C# Newtonsoft.Json 解析多嵌套json 进行反序列化
2021-04-01 17:27
标签:set 订单 blog price .json term reac fill int 上面为要解析的JSON数据 要用的对象类 效果图: 参考资料: http://blog.csdn.net/chinacsharper/article/details/9246627 http://blog.csdn.net/sgear/article/details/7587705 http://blog.csdn.net/leftfist/article/details/42435887 C# Newtonsoft.Json 解析多嵌套json 进行反序列化 标签:set 订单 blog price .json term reac fill int 原文地址:https://www.cnblogs.com/bwlluck/p/9233299.html[
{
"orderNo": "3213123123123",
"time": "2016-09-09 12:23:33",
"orderStatus": "1",
"freeShipping": true,
"fullCut": 20,
"originalCost": 340,
"actualPayment": 320,
"goods": [
{
"UserId": "5",
"GoodsId": "8",
"Total": 40,
"Number": 2,
"ConCcoin": 0,
"PayMode": "支付宝",
"Price": "20.00",
"goodsImg": "UpLoadImg/GoodsImage/546fda6d-8417-4b8f-bac6-3084dca420a9.jpg",
"shopname": "两颗牙",
"goodsTitle": "周村烧饼",
"manmoney": "200",
"jianmoney": "20",
"jianyoufei": "8"
},
{
"UserId": "5",
"GoodsId": "7",
"Total": 60,
"Number": 1,
"ConCcoin": 0,
"PayMode": "支付宝",
"Price": "60.00",
"goodsImg": "UpLoadImg/GoodsImage/931be419-e9d3-4dae-ae93-5af619c217d9.jpg",
"shopname": "两颗牙",
"goodsTitle": "山东特产山东大枣1000g",
"manmoney": "200",
"jianmoney": "0",
"jianyoufei": "10"
}
]
}
]
var json = "[{\"orderNo\": \"3213123123123\",\"time\": \"2016-09-09 12:23:33\",\"orderStatus\":\"1\", \"freeShipping\": true, \"fullCut\": 20,\"originalCost\": 340, \"actualPayment\": 320,\"goods\": [";
json += " {\"UserId\": \"5\",\"GoodsId\": \"8\", \"Total\": 40, \"Number\": 2, \"Price\": \"20.00\", \"shopname\": \"两颗牙\", \"manmoney\": \"200\", \"jianmoney\": \"0\",\"jianyoufei\": \"10\"},";
json += " {\"UserId\": \"5\",\"GoodsId\": \"7\", \"Total\": 60, \"Number\": 1, \"Price\": \"60.00\",\"shopname\": \"两颗牙\", \"manmoney\": \"200\", \"jianmoney\": \"0\",\"jianyoufei\": \"10\"},";
json += " ]} ]";
OrderDetails[] datas = JsonConvert.DeserializeObject
public class OrderDetailsInsert
{
public string orderno { get; set; }
public DateTime time { get; set; }
public char orderStatus { get; set; }
public Decimal actualPayment { get; set; }
public int GoodsId { get; set; }
public string Total { get; set; }
public int Number { get; set; }
public string Price { get; set; }
public string Remark { get; set; }
}
public class OrderDetails
{
public string orderno { get; set; }
public DateTime time { get; set; }
public char orderStatus { get; set; }
public bool freeShipping { get; set; }
public Decimal fullCut { get; set; }
public Decimal originalCost { get; set; }
public Decimal actualPayment { get; set; }
public GoodsInfoList[] goods { get; set; }
}
public class GoodsInfoList
{
public int UserId { get; set; }
public int GoodsId { get; set; }
public string Total { get; set; }
public int Number { get; set; }
public string Price { get; set; }
public string shopname { get; set; }
public string manmoney { get; set; }
}
文章标题:C# Newtonsoft.Json 解析多嵌套json 进行反序列化
文章链接:http://soscw.com/index.php/essay/71027.html