diff --git a/JdShopListener/JdShopListener/MainWindowViewModel.cs b/JdShopListener/JdShopListener/MainWindowViewModel.cs index ca598e5..656c75a 100644 --- a/JdShopListener/JdShopListener/MainWindowViewModel.cs +++ b/JdShopListener/JdShopListener/MainWindowViewModel.cs @@ -10,6 +10,7 @@ using JdShopListener.SqlHelpers; using System.Windows; using System.Linq; using System.Threading; +using Newtonsoft.Json.Linq; namespace JdShopListener { @@ -26,8 +27,6 @@ namespace JdShopListener } - - public MainWindowViewModel() { ProList = new System.Collections.ObjectModel.ObservableCollection() { new ProModel(){ Name="价格" , Type= ProType.Price}, @@ -227,25 +226,27 @@ namespace JdShopListener { var detail = GetItemDetail(Sku); - var list = detail.product.colorSize; + JArray list = detail.product.colorSize as JArray; //spuId string spuId = detail.product.mainSkuId; - //if (list.Count == 0 || list.Count == null) - //{ - // list.Add(new { skuId = Sku }); - //} + if (list==null||list.Count == 0) + { + list = new JArray(); + list.Add(JToken.FromObject(new { skuId=Sku })); + } List skus = new List(); - foreach (var sku in list) + + foreach (JObject sku in list) { SkuModel model = new SkuModel() { Desc = Desc, - SkuId = sku.skuId, + SkuId = sku["skuId"].ToString(), SpuId = spuId };