赞
踩
- public Class1()
- {
- string jsonData = "[{\"code\": \"LH201909100021\", \"customerCode\": \"80000000\", \"depositAmount\": \"179\", \"memberCode\": \"\", \"netAmount\": \"179\", \"orderAmount\": \"179\", \"orderType\": \"Z123\", \"pointOfService\": \"K900QTD014\", \"promotionDiscount\": \"0\", \"relPosOrder\": \"\", \"saleDate\": \"20191011172645\", \"salesCardType\": \"\", \"shopassistant\": \"onlinery\", \"specialDiscount\": \"\", \"standardDiscount\": \"\", \"temporaryDiscount\": \"\", \"totalDiscount\": \"0\" }, { \"code\": \"K210QTD0021191009092742\", \"customerCode\": \"0020005000\", \"depositAmount\": \"0\", \"memberCode\": \"SQ\", \"netAmount\": \"60\", \"orderAmount\": \"60\", \"orderType\": \"Z112\", \"pointOfService\": \"K210QTD002\", \"promotionDiscount\": \"0\", \"relPosOrder\": \"\", \"saleDate\": \"20191009093011\", \"salesCardType\": \"SQ\", \"shopassistant\": \"999\", \"specialDiscount\": \"0\", \"standardDiscount\": \"0\", \"temporaryDiscount\": \"0\", \"totalDiscount\": \"0\", \"hpaymentInfos\": [ { \"cardCode\": \"\", \"cardDisType\": \"\", \"discountAmount\": \"\", \"payAmount\": \"60\", \"paymentType\": \"ZG01\", \"pointAmount\": \"\", \"thirdDiscount\": \"\", \"thirdSubsidy\": \"\" } ], \"posOrderEntries\": [ { \"actualAmount\": \"30\", \"discountAmount\": \"0\", \"entryNumber\": \"1\", \"extracolumn\": \"K210QTD0021191009092742\", \"minsqty\": \"0\", \"netAmount\": \"60\", \"productCode\": \"000000008040600003\", \"promotionDiscount\": \"\", \"quantity\": \"2\", \"specialDiscount\": \"0\", \"standardDiscount\": \"0\", \"systemAmount\": \"30\", \"temporaryDiscount\": \"0\", \"cardIds\": [ { \"cardIds\": \"400000004452136649-400000004452136649\", \"quantity\": \"1\" }, { \"cardIds\": \"400000004452157237-400000004452157237\", \"quantity\": \"1\" } ] } ] } ]";
- List<KeyValue> jsonList = new List<KeyValue>();
- jsonList = DG(jsonData, jsonList);
- if (jsonList.Count > 0)
- {
-
- }
- }
- public class KeyValue
- {
- public string key { get; set; }
- public string value { get; set; }
- }
-
- public static List<KeyValue> DG(string json, List<KeyValue> strList)
- {
- //json = json.Replace("\r\n", string.Empty);
- //json = json.Replace("[", string.Empty);
- //json = json.Replace("]", string.Empty);
- JArray jar = (JArray)JsonConvert.DeserializeObject(json);
- foreach (JObject o in jar)
- {
-
- //var o = JObject.Parse(json);
- foreach (var x in o)
- {
- if (x.Value.GetType() == typeof(JObject) || (x.Value.GetType() == typeof(JArray)))
- {
- DG(x.Value.ToString(), strList);
- }
- else
- {
- KeyValue keyValue = new KeyValue();
- keyValue.key = x.Key;
- keyValue.value = x.Value.ToString();
- strList.Add(keyValue);
- }
-
- }
- }
- return strList;
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。