[
{
"orderNo": "",
"time": "2016-09-09 12:23:33",
"orderStatus": "",
"freeShipping": true,
"fullCut": ,
"originalCost": ,
"actualPayment": ,
"goods": [
{
"UserId": "",
"GoodsId": "",
"Total": ,
"Number": ,
"ConCcoin": ,
"PayMode": "支付宝",
"Price": "20.00",
"goodsImg": "UpLoadImg/GoodsImage/546fda6d-8417-4b8f-bac6-3084dca420a9.jpg",
"shopname": "两颗牙",
"goodsTitle": "周村烧饼",
"manmoney": "",
"jianmoney": "",
"jianyoufei": ""
},
{
"UserId": "",
"GoodsId": "",
"Total": ,
"Number": ,
"ConCcoin": ,
"PayMode": "支付宝",
"Price": "60.00",
"goodsImg": "UpLoadImg/GoodsImage/931be419-e9d3-4dae-ae93-5af619c217d9.jpg",
"shopname": "两颗牙",
"goodsTitle": "山东特产山东大枣1000g",
"manmoney": "",
"jianmoney": "",
"jianyoufei": ""
}
]
}
]

上面为要解析的JSON数据

 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<OrderDetails[]>(json);
List<OrderDetailsInsert> insert = new List<OrderDetailsInsert>();
foreach (OrderDetails data in datas)
{
var shopname = string.Empty;//判断是否同一个商家
foreach (var item in data.goods)
{
OrderDetailsInsert getinfo = new OrderDetailsInsert();
getinfo.orderno = data.orderno;
getinfo.time = data.time;
getinfo.orderStatus = data.orderStatus;
getinfo.actualPayment = data.actualPayment;
getinfo.orderno = data.orderno;
if (data.freeShipping == true)
{
getinfo.Remark = "此商品符合包邮条件及满" + item.manmoney + "减" + data.fullCut + "条件:订单总金额:" + data.originalCost + "符合满减条件减去:" + data.fullCut + "实际付款金额:" + data.actualPayment;
}
else if (!string.IsNullOrEmpty(data.fullCut.ToString()) && data.fullCut != )
{
getinfo.Remark = "此商品符合满" + item.manmoney + "减" + data.fullCut + "条件:订单总金额:" + data.originalCost + "符合满减条件减去:" + data.fullCut + "实际付款金额:" + data.actualPayment;
}
else
{
getinfo.Remark = "订单实际付款金额:" + data.actualPayment;
}
getinfo.GoodsId = item.GoodsId;
getinfo.Total = item.Total;
getinfo.Number = item.Number;
getinfo.Price = item.Price;
insert.Add(getinfo);
}
}

要用的对象类

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

效果图:

参考资料:

http://blog.csdn.net/chinacsharper/article/details/9246627

http://blog.csdn.net/sgear/article/details/7587705

http://blog.csdn.net/leftfist/article/details/42435887

最新文章

  1. 3小时搞定一个简单的MIS系统案例Northwind,有视频、有源代码下载、有真相
  2. T-Sql(五)xml操作
  3. 用html5 js实现浏览器全屏
  4. Java学习记录-Jdk包简单介绍
  5. .NET 动态脚本语言Script.NET 入门指南 Quick Start
  6. linux 安装python-setuptools
  7. centos安装redis3为系统服务
  8. php抽象 与接口
  9. HDU ACM 3177 Crixalis&#39;s Equipment
  10. [Angular2 Router] Programmatic Router Navigation via the Router API - Relative And Absolute Router Navigation
  11. tableview 在ios8上面分割线不全的问题
  12. 《python基础教程》笔记之 字符串
  13. Android 4.4环境搭建——Android SDK下载与安装
  14. 自学Zabbix1.1-简介
  15. ASP.NET没有魔法——ASP.NET MVC IoC代码篇
  16. C. Ayoub and Lost Array
  17. spring+springmvc+ibatis整合注解方式实例
  18. 敏捷开发— —Scrum 学习笔记
  19. Spark以yarn-client提交任务时报错超时,Connection to 192.168.. /has been quiet forms while there are outstanding requests. Failed to send RPC.....
  20. 请求(Request)的参数(Param)里包含特殊字符(#等)的正确处理方式

热门文章

  1. C# 使用消息队列,包括远程访问
  2. input type=&quot;image&quot; 提交表单
  3. sass基础2
  4. css 引入方式以及css的选择器
  5. linux文件按照行数切割
  6. 栅格那点儿事(四A)---栅格的显示与渲染
  7. 关于基于Linphone的视频通话Android端开发过程中遇到的问题
  8. android 学习之ViewDragHelper
  9. Myeclipse与tomcat的运行问题
  10. JavaScript 事件兼容性写法