class ProductModel { List result; ProductModel({this.result}); ProductModel.fromJson(Map json) { if (json['result'] != null) { result = new List(); json['result'].forEach((v) { result.add(new ProductItemModel.fromJson(v)); }); } } Map toJson() { final Map data = new Map(); if (this.result != null) { data['result'] = this.result.map((v) => v.toJson()).toList(); } return data; } } class ProductItemModel { String sId; String title; String cid; Object price; //所有的类型都继承 Object String oldPrice; String pic; String sPic; ProductItemModel( {this.sId, this.title, this.cid, this.price, this.oldPrice, this.pic, this.sPic}); ProductItemModel.fromJson(Map json) { sId = json['_id']; title = json['title']; cid = json['cid']; price = json['price']; oldPrice = json['old_price']; pic = json['pic']; sPic = json['s_pic']; } Map toJson() { final Map data = new Map(); data['_id'] = this.sId; data['title'] = this.title; data['cid'] = this.cid; data['price'] = this.price; data['old_price'] = this.oldPrice; data['pic'] = this.pic; data['s_pic'] = this.sPic; return data; } }