JSON转Dart
将JSON数据转换为Dart/Flutter模型
工具说明
此工具可以将JSON数据转换为Dart/Flutter模型,支持自定义类名、构造方法、fromJson/toJson方法等功能。生成的代码可以直接复制到Flutter项目中使用,提高开发效率。
使用场景
- Flutter应用中快速生成API请求/响应模型
- 解析JSON配置文件时生成对应数据结构
- 学习Dart类和json_serializable的使用
- 批量处理JSON数据时使用
示例JSON
用户信息
{
"id": 1,
"name": "John Doe",
"email": "john@example.com",
"age": 30,
"isActive": true,
"roles": ["admin", "user"],
"address": {
"street": "123 Main St",
"city": "New York",
"zipCode": "10001"
}
}API响应
{
"success": true,
"data": {
"items": [
{
"id": "123",
"title": "Product 1",
"price": 99.99
}
],
"total": 1,
"page": 1,
"pageSize": 10
},
"error": null,
"timestamp": 1634567890
}