Flutter开发之——json序列化,三面美团Android岗

本文介绍了Flutter应用中进行JSON序列化的步骤,重点讲解了如何创建序列化类Article及其内部数据结构。文章还提及了面试中可能遇到的Android相关问题,并提供了面试题及答案的文档资料,读者可以通过关注、点赞和访问作者的GitHub免费获取这些资源。
摘要由CSDN通过智能技术生成

dev_dependencies:

build_runner: ^2.0.3 #build_runner版本

json_serializable: ^4.1.2 #json_serializable版本

三 根据json创建序列化类


3.1 接口文件

  • API:https://www.wanandroid.com/article/list/0/json

3.2 序列化类(Article.dart)

import ‘package:json_annotation/json_annotation.dart’;

part ‘Article.g.dart’;

@JsonSerializable()

class Article {

int errorCode;

String errorMsg;

ArticleData data;

Article(this.errorCode, this.errorMsg, this.data);

factory Article.fromJson(Map<String, dynamic> json) => _$ArticleFromJson(json);

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

}

@JsonSerializable()

class ArticleData {

int curPage;

int offset;

bool over;

int pageCount;

int size;

int total;

List datas;

ArticleData(this.curPage, this.offset, this.over, this.pageCount, this.size, this.total, this.datas);

factory ArticleData.fromJson(Map<String, dynamic> json) => _$ArticleDataFromJson(json);

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

}

@JsonSerializable()

class Person {

String apkLink;

int audit;

String author;

bool canEdit;

int chapterId;

String chapterName;

bool collect;

int courseId;

String desc;

String descMd;

String envelopePic;

bool fresh;

String host;

int id;

String link;

String niceDate;

String niceShareDate;

String origin;

String prefix;

String projectLink;

int publishTime;

int realSuperChapterId;

int selfVisible;

int shareDate;

String shareUser;

int superChapterId;

String superChapterName;

List tags;

String title;

int type;

int userId;

int visible;

int zan;

Person(

this.apkLink,

this.audit,

this.author,

this.canEdit,

this.chapterId,

this.chapterName,

this.collect,

this.courseId,

this.desc,

this.descMd,

this.envelopePic,

this.fresh,

this.host,

this.id,

this.link,

this.niceDate,

this.niceShareDate,

this.origin,

this.prefix,

this.projectLink,

this.publishTime,

this.realSuperChapterId,

this.selfVisible,

this.shareDate,

this.shareUser,

this.superChapterId,

this.superChapterName,

this.tags,

this.title,

this.type,

this.userId,

this.visible,

this.zan);

结尾

我还总结出了互联网公司Android程序员面试涉及到的绝大部分面试题及答案,并整理做成了文档,以及系统的进阶学习视频资料,免费分享给大家。
(包括Java在Android开发中应用、APP框架知识体系、高级UI、全方位性能调优,NDK开发,音视频技术,人工智能技术,跨平台技术等技术资料),希望能帮助到你面试前的复习,且找到一个好的工作,也节省大家在网上搜索资料的时间来学习。

领取方式:关注+点赞+点击我的GitHub 免费获取

领取方式:关注+点赞+点击我的GitHub 免费获取

image

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值