Newtonsoft.Json.dll解析json的dll文件使用

要解析的json

//解析前

//解析前
{"orderlist":[{"backPrice":0,"businessId":93,"businessNotes":"","couponNo":"","createTime":{"date":9,"day":1,"hours":15,"minutes":35,"month":1,"seconds":8,"time":1423467308000,"timezoneOffset":-480,"year":115},"customerId":167193,"customerNickname":"","customerRemark":"","dealerType":"","delFlag":"0","distTrue":"","duShuPrice":"","evaluateFlag":"","expressDate":"","expressPrice":11,"fhPrice":"","getGoodsTime":{"date":17,"day":2,"hours":22,"minutes":55,"month":1,"seconds":45,"time":1424184945000,"timezoneOffset":-480,"year":115},"goodslist":[],"invoiceContent":"","invoiceTitle":"","invoiceType":"0","orderCancelRemark":"","orderCancelTime":null,"orderCode":"201502091535081953","orderId":2724,"orderIntegral":0,"orderOldCode":"","orderOldPrice":321,"orderPrePrice":0,"orderPrePriceOrder":0,"orderPrice":321,"orderRemark":"","orderStatus":"3","payId":1,"payTime":{"date":9,"day":1,"hours":15,"minutes":32,"month":1,"seconds":23,"time":1423467143000,"timezoneOffset":-480,"year":115},"sendExpressTime":{"date":10,"day":2,"hours":13,"minutes":30,"month":1,"seconds":37,"time":1423546237000,"timezoneOffset":-480,"year":115},"shippingAddress":"山西路43号省地税直属局","shippingCity":"南京","shippingCounty":"鼓楼区","shippingMobile":"15150512058","shippingPerson":"李玲","shippingPhone":"83633592","shippingPostcode":"210009","shippingProvince":"江苏","shoppingAddrId":1067,"unionPrice":"0.00","vipPrice":"321.00"},{"backPrice":0,"businessId":87,"businessNotes":"","couponNo":"","createTime":{"date":9,"day":1,"hours":11,"minutes":26,"month":1,"seconds":33,"time":1423452393000,"timezoneOffset":-480,"year":115},"customerId":167782,"customerNickname":"","customerRemark":"","dealerType":"","delFlag":"0","distTrue":"","duShuPrice":"199.20","evaluateFlag":"","expressDate":"","expressPrice":0,"fhPrice":"","getGoodsTime":{"date":19,"day":4,"hours":22,"minutes":55,"month":1,"seconds":42,"time":1424357742000,"timezoneOffset":-480,"year":115},"goodslist":[],"invoiceContent":"","invoiceTitle":"","invoiceType":"0","orderCancelRemark":"","orderCancelTime":null,"orderCode":"201502091126333935","orderId":2719,"orderIntegral":0,"orderOldCode":"","orderOldPrice":199.2,"orderPrePrice":0,"orderPrePriceOrder":0,"orderPrice":199.2,"orderRemark":"","orderStatus":"3","payId":1,"payTime":{"date":11,"day":3,"hours":11,"minutes":17,"month":1,"seconds":19,"time":1423624639000,"timezoneOffset":-480,"year":115},"sendExpressTime":{"date":12,"day":4,"hours":11,"minutes":24,"month":1,"seconds":47,"time":1423711487000,"timezoneOffset":-480,"year":115},"shippingAddress":"草场门大街88号江苏建设大厦2楼计划财务处","shippingCity":"南京","shippingCounty":"鼓楼区","shippingMobile":"18205088909","shippingPerson":"陈明伟","shippingPhone":"","shippingPostcode":"","shippingProvince":"江苏","shoppingAddrId":1130,"unionPrice":"0.00","vipPrice":""},{"backPrice":0,"businessId":93,"businessNotes":"","couponNo":"","createTime":{"date":9,"day":1,"hours":11,"minutes":11,"month":1,"seconds":25,"time":1423451485000,"timezoneOffset":-480,"year":115},"customerId":165780,"customerNickname":"","customerRemark":"","dealerType":"","delFlag":"0","distTrue":"","duShuPrice":"","evaluateFlag":"","expressDate":"","expressPrice":8,"fhPrice":"","getGoodsTime":{"date":17,"day":2,"hours":22,"minutes":55,"month":1,"seconds":45,"time":1424184945000,"timezoneOffset":-480,"year":115},"goodslist":[],"invoiceContent":"","invoiceTitle":"","invoiceType":"0","orderCancelRemark":"","orderCancelTime":null,"orderCode":"201502091111253041","orderId":2718,"orderIntegral":0,"orderOldCode":"","orderOldPrice":214,"orderPrePrice":0,"orderPrePriceOrder":0,"orderPrice":214,"orderRemark":"","orderStatus":"3","payId":1,"payTime":{"date":9,"day":1,"hours":11,"minutes":18,"month":1,"seconds":18,"time":1423451898000,"timezoneOffset":-480,"year":115},"sendExpressTime":{"date":10,"day":2,"hours":13,"minutes":31,"month":1,"seconds":16,"time":1423546276000,"timezoneOffset":-480,"year":115},"shippingAddress":"亭湖区黄海中路1号翰香花园1号楼705室13851180736","shippingCity":"盐城","shippingCounty":"盐城市","shippingMobile":"13851057736","shippingPerson":"仇玉海。晏泉","shippingPhone":"","shippingPostcode":"","shippingProvince":"江苏","shoppingAddrId":1387,"unionPrice":"0.00","vipPrice":"214.00"}],"status":"A001"}
View Code

个人用来记忆的,高手勿喷

 

1,开始解析

//ret表示要解析的json
var t = Newtonsoft.Json.JsonConvert.DeserializeObject(ret).ToString();

2,解析后

{
  "orderlist": [
    {
      "backPrice": 0,
      "businessId": 93,
      "businessNotes": "",
      "couponNo": "",
      "createTime": {
        "date": 9,
        "day": 1,
        "hours": 15,
        "minutes": 35,
        "month": 1,
        "seconds": 8,
        "time": 1423467308000,
        "timezoneOffset": -480,
        "year": 115
      },
      "customerId": 167193,
      "customerNickname": "",
      "customerRemark": "",
      "dealerType": "",
      "delFlag": "0",
      "distTrue": "",
      "duShuPrice": "",
      "evaluateFlag": "",
      "expressDate": "",
      "expressPrice": 11,
      "fhPrice": "",
      "getGoodsTime": {
        "date": 17,
        "day": 2,
        "hours": 22,
        "minutes": 55,
        "month": 1,
        "seconds": 45,
        "time": 1424184945000,
        "timezoneOffset": -480,
        "year": 115
      },
      "goodslist": [],
      "invoiceContent": "",
      "invoiceTitle": "",
      "invoiceType": "0",
      "orderCancelRemark": "",
      "orderCancelTime": null,
      "orderCode": "201502091535081953",
      "orderId": 2724,
      "orderIntegral": 0,
      "orderOldCode": "",
      "orderOldPrice": 321,
      "orderPrePrice": 0,
      "orderPrePriceOrder": 0,
      "orderPrice": 321,
      "orderRemark": "",
      "orderStatus": "3",
      "payId": 1,
      "payTime": {
        "date": 9,
        "day": 1,
        "hours": 15,
        "minutes": 32,
        "month": 1,
        "seconds": 23,
        "time": 1423467143000,
        "timezoneOffset": -480,
        "year": 115
      },
      "sendExpressTime": {
        "date": 10,
        "day": 2,
        "hours": 13,
        "minutes": 30,
        "month": 1,
        "seconds": 37,
        "time": 1423546237000,
        "timezoneOffset": -480,
        "year": 115
      },
      "shippingAddress": "山西路43号省地税直属局",
      "shippingCity": "南京",
      "shippingCounty": "鼓楼区",
      "shippingMobile": "15150512058",
      "shippingPerson": "李玲",
      "shippingPhone": "83633592",
      "shippingPostcode": "210009",
      "shippingProvince": "江苏",
      "shoppingAddrId": 1067,
      "unionPrice": "0.00",
      "vipPrice": "321.00"
    },
    {
      "backPrice": 0,
      "businessId": 87,
      "businessNotes": "",
      "couponNo": "",
      "createTime": {
        "date": 9,
        "day": 1,
        "hours": 11,
        "minutes": 26,
        "month": 1,
        "seconds": 33,
        "time": 1423452393000,
        "timezoneOffset": -480,
        "year": 115
      },
      "customerId": 167782,
      "customerNickname": "",
      "customerRemark": "",
      "dealerType": "",
      "delFlag": "0",
      "distTrue": "",
      "duShuPrice": "199.20",
      "evaluateFlag": "",
      "expressDate": "",
      "expressPrice": 0,
      "fhPrice": "",
      "getGoodsTime": {
        "date": 19,
        "day": 4,
        "hours": 22,
        "minutes": 55,
        "month": 1,
        "seconds": 42,
        "time": 1424357742000,
        "timezoneOffset": -480,
        "year": 115
      },
      "goodslist": [],
      "invoiceContent": "",
      "invoiceTitle": "",
      "invoiceType": "0",
      "orderCancelRemark": "",
      "orderCancelTime": null,
      "orderCode": "201502091126333935",
      "orderId": 2719,
      "orderIntegral": 0,
      "orderOldCode": "",
      "orderOldPrice": 199.2,
      "orderPrePrice": 0,
      "orderPrePriceOrder": 0,
      "orderPrice": 199.2,
      "orderRemark": "",
      "orderStatus": "3",
      "payId": 1,
      "payTime": {
        "date": 11,
        "day": 3,
        "hours": 11,
        "minutes": 17,
        "month": 1,
        "seconds": 19,
        "time": 1423624639000,
        "timezoneOffset": -480,
        "year": 115
      },
      "sendExpressTime": {
        "date": 12,
        "day": 4,
        "hours": 11,
        "minutes": 24,
        "month": 1,
        "seconds": 47,
        "time": 1423711487000,
        "timezoneOffset": -480,
        "year": 115
      },
      "shippingAddress": "草场门大街88号江苏建设大厦2楼计划财务处",
      "shippingCity": "南京",
      "shippingCounty": "鼓楼区",
      "shippingMobile": "18205088909",
      "shippingPerson": "陈明伟",
      "shippingPhone": "",
      "shippingPostcode": "",
      "shippingProvince": "江苏",
      "shoppingAddrId": 1130,
      "unionPrice": "0.00",
      "vipPrice": ""
    },
    {
      "backPrice": 0,
      "businessId": 93,
      "businessNotes": "",
      "couponNo": "",
      "createTime": {
        "date": 9,
        "day": 1,
        "hours": 11,
        "minutes": 11,
        "month": 1,
        "seconds": 25,
        "time": 1423451485000,
        "timezoneOffset": -480,
        "year": 115
      },
      "customerId": 165780,
      "customerNickname": "",
      "customerRemark": "",
      "dealerType": "",
      "delFlag": "0",
      "distTrue": "",
      "duShuPrice": "",
      "evaluateFlag": "",
      "expressDate": "",
      "expressPrice": 8,
      "fhPrice": "",
      "getGoodsTime": {
        "date": 17,
        "day": 2,
        "hours": 22,
        "minutes": 55,
        "month": 1,
        "seconds": 45,
        "time": 1424184945000,
        "timezoneOffset": -480,
        "year": 115
      },
      "goodslist": [],
      "invoiceContent": "",
      "invoiceTitle": "",
      "invoiceType": "0",
      "orderCancelRemark": "",
      "orderCancelTime": null,
      "orderCode": "201502091111253041",
      "orderId": 2718,
      "orderIntegral": 0,
      "orderOldCode": "",
      "orderOldPrice": 214,
      "orderPrePrice": 0,
      "orderPrePriceOrder": 0,
      "orderPrice": 214,
      "orderRemark": "",
      "orderStatus": "3",
      "payId": 1,
      "payTime": {
        "date": 9,
        "day": 1,
        "hours": 11,
        "minutes": 18,
        "month": 1,
        "seconds": 18,
        "time": 1423451898000,
        "timezoneOffset": -480,
        "year": 115
      },
      "sendExpressTime": {
        "date": 10,
        "day": 2,
        "hours": 13,
        "minutes": 31,
        "month": 1,
        "seconds": 16,
        "time": 1423546276000,
        "timezoneOffset": -480,
        "year": 115
      },
      "shippingAddress": "亭湖区黄海中路1号翰香花园1号楼705室13851180736",
      "shippingCity": "盐城",
      "shippingCounty": "盐城市",
      "shippingMobile": "13851057736",
      "shippingPerson": "仇玉海。晏泉",
      "shippingPhone": "",
      "shippingPostcode": "",
      "shippingProvince": "江苏",
      "shoppingAddrId": 1387,
      "unionPrice": "0.00",
      "vipPrice": "214.00"
    }
  ],
  "status": "A001"
}
View Code

3,根据解析后的json,用JObject.Parse(t)[]获取对应数据

List<JToken> list = JObject.Parse(t)["orderlist"].ToList();

4,循环list

 

你可能感兴趣的:(json)