toJson method

  1. @override
Map<String, dynamic> toJson()
override

Implementation

@override
Map<String, dynamic> toJson() {
  final jsonMap = super.toJson();
  jsonMap['@type'] = type;
  if (id != null) jsonMap['@id'] = id;
  if (hasTiers != null && hasTiers!.isNotEmpty) {
    if (hasTiers!.length == 1) {
      final val = hasTiers![0];
      jsonMap['hasTiers'] = (val is String || val is num || val is bool) ? val : (val as dynamic).toJson();
    } else {
      jsonMap['hasTiers'] = hasTiers!.map((e) => (e is String || e is num || e is bool) ? e : (e as dynamic).toJson()).toList();
    }
  }
  if (hostingOrganization != null && hostingOrganization!.isNotEmpty) {
    if (hostingOrganization!.length == 1) {
      final val = hostingOrganization![0];
      jsonMap['hostingOrganization'] = (val is String || val is num || val is bool) ? val : (val as dynamic).toJson();
    } else {
      jsonMap['hostingOrganization'] = hostingOrganization!.map((e) => (e is String || e is num || e is bool) ? e : (e as dynamic).toJson()).toList();
    }
  }
  return jsonMap;
}