Single response: customer profile
One response from a customer endpoint with a nested object, a list of strings, a list of orders and a null value. The order totals mix whole and decimal numbers, so they become double, and one order has an extra coupon field, so coupon becomes nullable. Root class name: CustomerProfile.
Input JSON
{
"id": 1024,
"full_name": "Amina Rahman",
"email": "amina@example.com",
"is_verified": true,
"rating": 4.8,
"avatar_url": null,
"address": {
"line1": "Office 1204, Bay Square",
"city": "Dubai",
"country_code": "AE"
},
"tags": ["wholesale", "priority"],
"recent_orders": [
{
"order_id": "SO-55120",
"total": 1250.5,
"item_count": 3,
"placed_at": "2026-10-28T09:15:00Z"
},
{
"order_id": "SO-55187",
"total": 980,
"item_count": 2,
"placed_at": "2026-10-30T14:02:00Z",
"coupon": "AUTUMN10"
}
]
}
Generated Dart (customer_profile.dart)
// Generated by Zvaad Tools: JSON to Dart Model Generator.
// https://tools.zvaad.com/json-to-dart/
class CustomerProfile {
const CustomerProfile({
required this.id,
required this.fullName,
required this.email,
required this.isVerified,
required this.rating,
this.avatarUrl,
required this.address,
required this.tags,
required this.recentOrders,
});
factory CustomerProfile.fromJson(Map<String, dynamic> json) {
return CustomerProfile(
id: (json['id'] as num).toInt(),
fullName: json['full_name'] as String,
email: json['email'] as String,
isVerified: json['is_verified'] as bool,
rating: (json['rating'] as num).toDouble(),
avatarUrl: json['avatar_url'],
address: Address.fromJson(json['address'] as Map<String, dynamic>),
tags: (json['tags'] as List<dynamic>).map((e) => e as String).toList(),
recentOrders: (json['recent_orders'] as List<dynamic>).map((e) => RecentOrder.fromJson(e as Map<String, dynamic>)).toList(),
);
}
final int id;
final String fullName;
final String email;
final bool isVerified;
final double rating;
final dynamic avatarUrl;
final Address address;
final List<String> tags;
final List<RecentOrder> recentOrders;
Map<String, dynamic> toJson() {
return <String, dynamic>{
'id': id,
'full_name': fullName,
'email': email,
'is_verified': isVerified,
'rating': rating,
'avatar_url': avatarUrl,
'address': address.toJson(),
'tags': tags,
'recent_orders': recentOrders.map((e) => e.toJson()).toList(),
};
}
}
class Address {
const Address({
required this.line1,
required this.city,
required this.countryCode,
});
factory Address.fromJson(Map<String, dynamic> json) {
return Address(
line1: json['line1'] as String,
city: json['city'] as String,
countryCode: json['country_code'] as String,
);
}
final String line1;
final String city;
final String countryCode;
Map<String, dynamic> toJson() {
return <String, dynamic>{
'line1': line1,
'city': city,
'country_code': countryCode,
};
}
}
class RecentOrder {
const RecentOrder({
required this.orderId,
required this.total,
required this.itemCount,
required this.placedAt,
this.coupon,
});
factory RecentOrder.fromJson(Map<String, dynamic> json) {
return RecentOrder(
orderId: json['order_id'] as String,
total: (json['total'] as num).toDouble(),
itemCount: (json['item_count'] as num).toInt(),
placedAt: json['placed_at'] as String,
coupon: json['coupon'] as String?,
);
}
final String orderId;
final double total;
final int itemCount;
final String placedAt;
final String? coupon;
Map<String, dynamic> toJson() {
return <String, dynamic>{
'order_id': orderId,
'total': total,
'item_count': itemCount,
'placed_at': placedAt,
'coupon': coupon,
};
}
}
- Type fallback · avatar_url: Only null values were found, so the type is dynamic. Add a sample with a real value to get a specific type.
- Type fallback · recent_orders[].total: Both integers and decimal numbers were found, so the type is double. Integers are converted with toDouble().
- Nullable · recent_orders[].coupon: Nullable because the field is missing from 1 of 2 objects (response 1).