SBOM-2023-main/metrics-computation/src/main/java/io/github/chains_project/JsonReader.java
package io.github.chains_project;

import java.nio.file.Path;
import java.util.List;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.chains_project.data.Dependency;

public class JsonReader implements FileReader {
  
  private static final ObjectMapper mapper = new ObjectMapper();

  @Override
  public List<Dependency> readFile(Path path) {
    try {
      return mapper.readValue(path.toFile(), mapper.getTypeFactory().constructCollectionType(List.class, Dependency.class));
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
}
