AnalysisSetSubscriptionsParams.fromJson constructor

AnalysisSetSubscriptionsParams.fromJson(
  1. JsonDecoder jsonDecoder,
  2. String jsonPath,
  3. Object? json, {
  4. ClientUriConverter? clientUriConverter,
})

Implementation

factory AnalysisSetSubscriptionsParams.fromJson(
  JsonDecoder jsonDecoder,
  String jsonPath,
  Object? json, {
  ClientUriConverter? clientUriConverter,
}) {
  json ??= {};
  if (json is! Map) {
    throw jsonDecoder.mismatch(
      jsonPath,
      "'analysis.setSubscriptions params'",
      json,
    );
  }
  Map<AnalysisService, List<String>> subscriptions;
  if (json case {'subscriptions': var encodedSubscriptions}) {
    subscriptions = jsonDecoder.decodeMap(
      '$jsonPath.subscriptions',
      encodedSubscriptions,
      keyDecoder: (String jsonPath, Object? json) => AnalysisService.fromJson(
        jsonDecoder,
        jsonPath,
        json,
        clientUriConverter: clientUriConverter,
      ),
      valueDecoder: (String jsonPath, Object? json) => jsonDecoder.decodeList(
        jsonPath,
        json,
        (String jsonPath, Object? json) =>
            clientUriConverter?.fromClientFilePath(
              jsonDecoder.decodeString(jsonPath, json),
            ) ??
            jsonDecoder.decodeString(jsonPath, json),
      ),
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'subscriptions'", json);
  }
  return AnalysisSetSubscriptionsParams(subscriptions);
}