toJson method

  1. @override
List toJson()

Converts this class object into a JSON value.

Implementation

@override
List<dynamic> toJson() {
  final result = <dynamic>[];
  final mapResult = <String, String>{};

  for (final contextEntry in contextEntries) {
    switch (contextEntry) {
      case SingleContextEntry(:final uri):
        result.add(uri.toString());
      case MapContextEntry(:final key, :final value):
        //TODO: Could there be duplicate keys?
        mapResult[key] = value;
    }
  }

  if (mapResult.isNotEmpty) {
    result.add(mapResult);
  }

  return result;
}