package com.rcv;

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

// Jackson wrapper to help parse json into rcv objects
public class JsonParser {

  // TODO: add logging and recovery logic
  public static <T> T parseObjectFromFile(String jsonFilePath, Class<T> valueType) {
    try {
      ObjectMapper electionMapper = new ObjectMapper();
      FileReader electionReader = new FileReader(jsonFilePath);
      T object = electionMapper.readValue(electionReader, valueType);
      return object;
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (JsonParseException e) {
      e.printStackTrace();
    } catch (JsonMappingException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
    return null;
  }

}



@@ -510,24 +510,22 @@
 tMapper 
-election
+object
 Mapper =
@@ -562,24 +562,20 @@
 eReader 
-election
+file
 Reader =
@@ -622,24 +622,22 @@
 bject = 
-election
+object
 Mapper.r
@@ -649,16 +649,12 @@
 lue(
-election
+file
 Read

fix variable names