JdProduct.fromJson constructor
JdProduct.fromJson(
- Map<String, dynamic> jsonRes
)
Implementation
factory JdProduct.fromJson(Map<String, dynamic> jsonRes) {
final List<String>? smallImages =
jsonRes['smallImages'] is List ? <String>[] : null;
if (smallImages != null) {
for (final dynamic item in jsonRes['smallImages']!) {
if (item != null) {
tryCatch(() {
smallImages.add(asT<String>(item)!);
});
}
}
}
final List<Object>? videoUrlList =
jsonRes['videoUrlList'] is List ? <Object>[] : null;
if (videoUrlList != null) {
for (final dynamic item in jsonRes['videoUrlList']!) {
if (item != null) {
tryCatch(() {
videoUrlList.add(asT<Object>(item)!);
});
}
}
}
final List<Object>? detailImages =
jsonRes['detailImages'] is List ? <Object>[] : null;
if (detailImages != null) {
for (final dynamic item in jsonRes['detailImages']!) {
if (item != null) {
tryCatch(() {
detailImages.add(asT<Object>(item)!);
});
}
}
}
final List<Object>? promotionLabelList =
jsonRes['promotionLabelList'] is List ? <Object>[] : null;
if (promotionLabelList != null) {
for (final dynamic item in jsonRes['promotionLabelList']!) {
if (item != null) {
tryCatch(() {
promotionLabelList.add(asT<Object>(item)!);
});
}
}
}
return JdProduct(
couponReceiveCount: asT<int>(jsonRes['couponReceiveCount'])!,
materialUrl: asT<String>(jsonRes['materialUrl'])!,
actualPrice: asT<double>(jsonRes['actualPrice'])!,
isFlagship: asT<int>(jsonRes['isFlagship'])!,
commissionStartTime: asT<String>(jsonRes['commissionStartTime'])!,
isFreeShipping: asT<int>(jsonRes['isFreeShipping'])!,
shopName: asT<String>(jsonRes['shopName'])!,
originPrice: asT<double>(jsonRes['originPrice'])!,
skuName: asT<String>(jsonRes['skuName'])!,
smallImages: smallImages!,
couponLink: asT<String>(jsonRes['couponLink'])!,
couponAmount: asT<int>(jsonRes['couponAmount'])!,
cid2Name: asT<String>(jsonRes['cid2Name'])!,
isOwner: asT<int>(jsonRes['isOwner'])!,
commissionShare: asT<double>(jsonRes['commissionShare'])!,
commissionEndTime: asT<String>(jsonRes['commissionEndTime'])!,
couponType: asT<int>(jsonRes['couponType'])!,
couponStartTime: asT<String>(jsonRes['couponStartTime'])!,
cid2: asT<int>(jsonRes['cid2'])!,
commission: asT<double>(jsonRes['commission'])!,
cid3: asT<int>(jsonRes['cid3'])!,
shopId: asT<int>(jsonRes['shopId'])!,
cid1: asT<int>(jsonRes['cid1'])!,
picMain: asT<String>(jsonRes['picMain'])!,
skuId: asT<int>(jsonRes['skuId'])!,
extensionContent: asT<String>(jsonRes['extensionContent'])!,
cid1Name: asT<String>(jsonRes['cid1Name'])!,
videoUrlList: videoUrlList!,
couponRemainCount: asT<int>(jsonRes['couponRemainCount'])!,
comments: asT<int>(jsonRes['comments'])!,
couponConditions: asT<String>(jsonRes['couponConditions'])!,
isFreeFreightRisk: asT<int>(jsonRes['isFreeFreightRisk'])!,
couponUseStartTime: asT<String>(jsonRes['couponUseStartTime'])!,
inOrderCount30Days: asT<int>(jsonRes['inOrderCount30Days'])!,
couponEndTime: asT<String>(jsonRes['couponEndTime'])!,
couponTotalCount: asT<int>(jsonRes['couponTotalCount'])!,
goodsCommentShare: asT<double>(jsonRes['goodsCommentShare'])!,
couponUserEndTime: asT<String>(jsonRes['couponUserEndTime'])!,
detailImages: detailImages!,
isSeckill: asT<int>(jsonRes['isSeckill'])!,
promotionLabelList: promotionLabelList!,
cid3Name: asT<String>(jsonRes['cid3Name'])!,
productIntro: asT<String>(jsonRes['productIntro'])!,
);
}