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) {
    Map<AnalysisService, List<String>> subscriptions;
    if (json.containsKey('subscriptions')) {
      subscriptions = jsonDecoder.decodeMap(
        '$jsonPath.subscriptions',
        json['subscriptions'],
        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');
    }
    return AnalysisSetSubscriptionsParams(subscriptions);
  } else {
    throw jsonDecoder.mismatch(
      jsonPath,
      'analysis.setSubscriptions params',
      json,
    );
  }
}