hot_goods_model.dart 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. class HotGoodsModel {
  2. String code;
  3. String message;
  4. List<HotGoodsData> data;
  5. HotGoodsModel({this.code, this.message, this.data});
  6. HotGoodsModel.fromJson(Map<String, dynamic> json) {
  7. code = json['code'];
  8. message = json['message'];
  9. if (json['data'] != null) {
  10. data = new List<HotGoodsData>();
  11. json['data'].forEach((v) {
  12. data.add(new HotGoodsData.fromJson(v));
  13. });
  14. }
  15. }
  16. Map<String, dynamic> toJson() {
  17. final Map<String, dynamic> data = new Map<String, dynamic>();
  18. data['code'] = this.code;
  19. data['message'] = this.message;
  20. if (this.data != null) {
  21. data['data'] = this.data.map((v) => v.toJson()).toList();
  22. }
  23. return data;
  24. }
  25. }
  26. class HotGoodsData {
  27. String name;
  28. String image;
  29. double mallPrice;
  30. String goodsId;
  31. double price;
  32. HotGoodsData({this.name, this.image, this.mallPrice, this.goodsId, this.price});
  33. HotGoodsData.fromJson(Map<String, dynamic> json) {
  34. name = json['name'];
  35. image = json['image'];
  36. mallPrice = json['mallPrice'] + 0.0;
  37. goodsId = json['goodsId'];
  38. price = json['price'] + 0.0;
  39. }
  40. Map<String, dynamic> toJson() {
  41. final Map<String, dynamic> data = new Map<String, dynamic>();
  42. data['name'] = this.name;
  43. data['image'] = this.image;
  44. data['mallPrice'] = this.mallPrice;
  45. data['goodsId'] = this.goodsId;
  46. data['price'] = this.price;
  47. return data;
  48. }
  49. static List<HotGoodsData> fromMapList(dynamic mapList) {
  50. List<HotGoodsData> list = [];
  51. mapList.forEach((map) {
  52. list.add(HotGoodsData.fromJson(map));
  53. });
  54. return list;
  55. }
  56. }