fromJson static method

Person? fromJson(
  1. Map<String, dynamic>? json
)

Returns a new Person instance and imports its values from json if it's non-null, null if json is null.

Implementation

static Person? fromJson(Map<String, dynamic>? json) {
  if (json == null) {
    return null;
  }

  DateTime? createdAt =
      json[r'createdAt'] == null ? null : DateTime.parse(json[r'createdAt']);
  if (createdAt != null && createdAt.isUtc == false) {
    createdAt = DateTime.parse('${json[r'createdAt']}Z');
  }

  DateTime? updatedAt =
      json[r'updatedAt'] == null ? null : DateTime.parse(json[r'updatedAt']);
  if (updatedAt != null && updatedAt.isUtc == false) {
    updatedAt = DateTime.parse('${json[r'updatedAt']}Z');
  }

  return Person(
    links: PersonLinks.fromJson(json[r'_links']),
    agreement: PersonAgreement.fromJson(json[r'agreement']),
    createdAt: createdAt,
    email: json[r'email'],
    enabled: json[r'enabled'],
    familyName: json[r'familyName'],
    givenName: json[r'givenName'],
    id: json[r'id'],
    jobTitle: json[r'jobTitle'],
    optIn: json[r'optIn'],
    preferences: PersonPreferences.fromJson(json[r'preferences']),
    telephone: json[r'telephone'],
    type: json[r'type'],
    updatedAt: updatedAt,
    username: json[r'username'],
  );
}