toJson method

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

Converts this class object into a JSON value.

Implementation

@mustCallSuper
@override
Map<String, dynamic> toJson() {
  final result = <String, dynamic>{
    "scheme": scheme,
    ...additionalFields,
  };

  final keyValuePairs = [
    ("description", description),
    ("descriptions", descriptions),
    ("@type", jsonLdType),
    ("proxy", proxy),
  ];

  for (final (key, value) in keyValuePairs) {
    final dynamic convertedValue;

    switch (value) {
      case null:
        continue;
      case Uri():
        convertedValue = value.toString();
      default:
        convertedValue = value;
    }

    result[key] = convertedValue;
  }

  return result;
}