toJson method
Converts the full user model to JSON.
Implementation
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
if (id != null) json['_id'] = id;
if (token != null) json['token'] = token;
if (roles != null) json['roles'] = roles;
if (created != null) json['created'] = created!.toIso8601String();
if (modified != null) json['modified'] = modified!.toIso8601String();
final userData = <String, dynamic>{};
if (email != null) userData['email'] = email;
if (data != null) userData.addAll(data!);
json['data'] = userData;
return json;
}