Guest User

Untitled

a guest
Jan 22nd, 2018
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. {
  2. "2": {
  3. "sell_average": 239,
  4. "buy_average": 238,
  5. "overall_average": 240,
  6. "id": 2
  7. },
  8. "6": {
  9. "sell_average": 184434,
  10. "buy_average": 182151,
  11. "overall_average": 189000,
  12. "id": 6
  13. },
  14. "8": {
  15. "sell_average": 11201,
  16. "buy_average": 1723,
  17. "overall_average": 180,
  18. "id": 8
  19. }
  20. }
  21.  
  22. public class ItemSummaryModel
  23. {
  24. public string Id { get; set; }
  25. public ItemSummary ItemSummary { get; set; }
  26. }
  27.  
  28. public class ItemSummary
  29. {
  30. public int Sell_Average { get; set; }
  31. public int Buy_Average { get; set; }
  32. public int Overall_Average { get; set; }
  33. public int Id { get; set; }
  34. }
  35.  
  36. List<ItemSummaryModel> models =
  37. JsonConvert.DeserializeObject<List<ItemSummaryModel>>(jsonSummary);
  38.  
  39. var dict = JsonConvert.DeserializeObject<Dictionary<int, ItemSummary>>(json);
  40. var items = dict.Values.ToList(); //if you want a List<ItemSummary>;
  41.  
  42. public class ItemSummaryModel
  43. {
  44. [JsonProperty(PropertyName = "2")]
  45. public ItemSummary Two { get; set; }
  46. [JsonProperty(PropertyName = "6")]
  47. public ItemSummary Six { get; set; }
  48. [JsonProperty(PropertyName = "8")]
  49. public ItemSummary Eight { get; set; }
  50. }
  51.  
  52. var result = JsonConvert.DeserializeObject<ItemSummaryModel>(json);
Add Comment
Please, Sign In to add comment