【发布时间】:2022-01-31 15:11:29
【问题描述】:
Shippingmodel shippingmodelFromJson(String str) => Shippingmodel.fromJson(json.decode(str));
String shippingmodelToJson(Shippingmodel data) => json.encode(data.toJson());
class Shippingmodel {
Shippingmodel({
this.sellerShipping,
this.result,
this.shippingType,
this.value,
this.valueString,
});
Map<String, List<SellerShipping>> sellerShipping;
bool result;
String shippingType;
int value;
String valueString;
factory Shippingmodel.fromJson(Map<String, dynamic> json) => Shippingmodel(
sellerShipping: Map.from(json["seller_shipping"]).map((k, v) => MapEntry<String, List<SellerShipping>>(k, List<SellerShipping>.from(v.map((x) => SellerShipping.fromJson(x))))),
result: json["result"],
shippingType: json["shipping_type"],
value: json["value"],
valueString: json["value_string"],
);
Map<String, dynamic> toJson() => {
"seller_shipping": Map.from(sellerShipping).map((k, v) => MapEntry<String, dynamic>(k, List<dynamic>.from(v.map((x) => x.toJson())))),
"result": result,
"shipping_type": shippingType,
"value": value,
"value_string": valueString,
};
}
class SellerShipping {
SellerShipping({
this.code,
this.name,
this.price,
this.deadline,
this.erroMsg,
});
String code;
String name;
String price;
String deadline;
String erroMsg;
factory SellerShipping.fromJson(Map<String, dynamic> json) => SellerShipping(
code: json["code"],
name: json["name"],
price: json["price"],
deadline: json["deadline"],
erroMsg: json["erroMsg"],
);
Map<String, dynamic> toJson() => {
"code": code,
"name": name,
"price": price,
"deadline": deadline,
"erroMsg": erroMsg,
};
}
这是 json 数据模型。我对如何取回任何东西感到困惑,比如卖家航运的价格。我从存储库中调用它并传递响应。身体。任何帮助将不胜感激!
这是 json 数据模型。我对如何取回任何东西感到困惑,比如卖家航运的价格。我从存储库中调用它并传递响应。身体。任何帮助将不胜感激!
【问题讨论】:
标签: json flutter android-studio dart hashmap