【flutter】序列化

1、导入插件

dependencies:
  json_annotation: ^3.0.0   #序列化
dev_dependencies:
  json_serializable: ^3.2.3
  build_runner: ^1.6.1    #

2、要序列化的bean

import 'package:json_annotation/json_annotation.dart';
part 'order.g.dart';
@JsonSerializable()
class Order {
  String order_id; //订单主键
  String order_no; //订单号
  String order_waybill_no; //运单号
  String order_create_time; //订单创建时间
  String order_pay_time; //付款时间
  String order_send_time; //发货时间
  String order_complete_time; //交易完成时间
  String order_shop_name; //商品名称
  String order_shop_price; //商品单价
  String order_shop_tax; //税金
  String order_shop_freight; //运费
  String order_shop_count; //商品数量
  String order_shop_total_price; //商品总价
  String order_receive_name; //收货人
  String order_receive_phone; //收货人手机号
  String order_receive_idcard; //收货人身份证号
  String order_receive_address; //收货地址
  String order_express_company; //物流公司
  String order_member_name; //会员姓名
  String order_member_level; //会员等级
  String shop_id; //商铺主键
  String member_id; //会员主键
  String commodity_id; //商品主键
  String order_status; //订单状态(0:待付款,1:待发货,2:待收货,3:交易完成,4:订单取消)
  String order_shop_specification; //商品规格
  String shop_name;//店铺名称

  Order({
    this.order_id, //订单主键
    this.order_no, //订单号
    this.order_waybill_no, //运单号
    this.order_create_time, //订单创建时间
    this.order_pay_time, //付款时间
    this.order_send_time, //发货时间
    this.order_complete_time, //交易完成时间
    this.order_shop_name, //商品名称
    this.order_shop_price, //商品单价
    this.order_shop_tax, //税金
    this.order_shop_freight, //运费
    this.order_shop_count, //商品数量
    this.order_shop_total_price, //商品总价
    this.order_receive_name, //收货人
    this.order_receive_phone, //收货人手机号
    this.order_receive_idcard, //收货人身份证号
    this.order_receive_address, //收货地址
    this.order_express_company, //物流公司
    this.order_member_name, //会员姓名
    this.order_member_level, //会员等级
    this.shop_id, //商铺主键
    this.member_id, //会员主键
    this.commodity_id, //商品主键
    this.order_status, //订单状态(0:待付款,1:待发货,2:待收货,3:交易完成,4:订单取消)
    this.order_shop_specification, //商品规格
    this.shop_name,//店铺名称
  });
  factory Order.fromJson(Map<String, dynamic> json) =>
      _$OrderFromJson(json);

  Map<String, dynamic> toJson() => _$OrderToJson(this);
}


3、运行

flutter packages pub run build_runner build

4、根据需求 自己改动

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值