- Flutter/Android developer.
- Open source.
caijinglong / json2dart Goto Github PK
View Code? Open in Web Editor NEWLicense: BSD 2-Clause "Simplified" License
License: BSD 2-Clause "Simplified" License
JSON
{
"id":"487349",
"name":"Pooja Bhaumik",
"score" : 45
}
转换完成后是
StudentModel(this.id,this.name,this.score,);
一般可能需要,不知道有什么方法吗
StudentModel({this.id, this.name, this.score});
dart
生成之后的数据,能默认加上final修饰和可选类型吗,
No response
{
"itemList": [
{
"data": {
"itemList": [
{
"data": {}
}
]
}
}
]
}
类似于这种json, 转换得到的结果:
@JsonSerializable()
class ItemList extends Object {
@JsonKey(name: 'data')
Data data;
ItemList(this.data,);
factory ItemList.fromJson(Map<String, dynamic> srcJson) => _$ItemListFromJson(srcJson);
Map<String, dynamic> toJson() => _$ItemListToJson(this);
}
@JsonSerializable()
class Data extends Object {
@JsonKey(name: 'itemList')
List<ItemList> itemList;
Data(this.itemList,);
factory Data.fromJson(Map<String, dynamic> srcJson) => _$DataFromJson(srcJson);
Map<String, dynamic> toJson() => _$DataToJson(this);
}
@JsonSerializable()
class ItemList extends Object {
@JsonKey(name: 'data')
Data data;
ItemList(this.data,);
factory ItemList.fromJson(Map<String, dynamic> srcJson) => _$ItemListFromJson(srcJson);
Map<String, dynamic> toJson() => _$ItemListToJson(this);
}
@JsonSerializable()
class Data extends Object {
Data();
factory Data.fromJson(Map<String, dynamic> srcJson) => _$DataFromJson(srcJson);
Map<String, dynamic> toJson() => _$DataToJson(this);
}
同个dart文件夹里ItemList和Data类重复。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.