ToolHub
中文
Light
GitHub
返回首页
/
数据格式
/
JSON 转 Dart / Rust / Swift / Kotlin / Python
加载中...
Dart
Rust
Swift
Kotlin
Python
类名
示例
JSON
{ "id": 1, "name": "John Doe", "email": "john@example.com", "age": 30, "is_active": true, "score": 95.5, "tags": ["developer", "mobile"], "address": { "street": "123 Main St", "city": "New York", "zip_code": "10001" } }
Dart
class Address { final String street; final String city; final String zipCode; Address({ required this.street, required this.city, required this.zipCode, }); factory Address.fromJson(Map<String, dynamic> json) { return Address( street: json['street'], city: json['city'], zipCode: json['zip_code'], ); } } class AutoGenerated { final int id; final String name; final String email; final int age; final bool isActive; final double score; final List<String> tags; final Address address; AutoGenerated({ required this.id, required this.name, required this.email, required this.age, required this.isActive, required this.score, required this.tags, required this.address, }); factory AutoGenerated.fromJson(Map<String, dynamic> json) { return AutoGenerated( id: json['id'], name: json['name'], email: json['email'], age: json['age'], isActive: json['is_active'], score: json['score'], tags: List<dynamic>.from(json['tags']), address: json['address'], ); } }