ExtractLocalVariableOptions.fromJson constructor

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

Implementation

factory ExtractLocalVariableOptions.fromJson(
  JsonDecoder jsonDecoder,
  String jsonPath,
  Object? json, {
  ClientUriConverter? clientUriConverter,
}) {
  json ??= {};
  if (json is! Map) {
    throw jsonDecoder.mismatch(
      jsonPath,
      "'extractLocalVariable options'",
      json,
    );
  }
  String name;
  if (json case {'name': var encodedName}) {
    name = jsonDecoder.decodeString('$jsonPath.name', encodedName);
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'name'", json);
  }
  bool extractAll;
  if (json case {'extractAll': var encodedExtractAll}) {
    extractAll = jsonDecoder.decodeBool(
      '$jsonPath.extractAll',
      encodedExtractAll,
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'extractAll'", json);
  }
  return ExtractLocalVariableOptions(name, extractAll);
}