diff --git a/DataWriter.py b/DataWriter.py
index 80496f5..b4fee64 100644
--- a/DataWriter.py
+++ b/DataWriter.py
@@ -1,3 +1,7 @@
+import json
+import os
+
+
 class DataWriter:
     def __init__(self, hrm):
         """Constructor for DataWriter Object
@@ -10,3 +14,46 @@ class DataWriter:
         """
 
         self.metrics = hrm.output_dict
+        self.csv_file = hrm.csv_file
+        output_file = self.get_output_file_name(self.csv_file)
+
+    def get_output_file_name(self, csv_file):
+        """Finds the root file name (i.e. the file name without the .csv
+        extension) and creates a file name that is equivalent but with a
+        .json extension.
+
+        Parameters
+        ----------
+        csv_file:   str
+                    A string with the CSV file path
+
+        Returns
+        -------
+        output_file str
+                    The output file path, which is the same as the csv_file
+                    name with a .json extension instead of a .csv extension
+
+        """
+        root_file_name = os.path.splitext(csv_file)[0]
+        output_file = root_file_name + ".json"
+        return output_file
+
+    def write_to_json(self, metrics, filename):
+        """Writes the metrics dictionary to the specified filename as a JSON
+        file.
+
+        Parameters
+        ----------
+        metrics:    dict
+                    A dictionary containing the relevant ECG output
+                    parameters associated with the heart rate monitor.
+        filename:   str
+                    A string specifying the desired file output path
+
+        Returns
+        -------
+        None
+        """
+
+        with open(filename, 'w') as outfile:
+            json.dump(metrics, outfile)
diff --git a/HRM_Processor.py b/HRM_Processor.py
index b963222..91d642b 100644
--- a/HRM_Processor.py
+++ b/HRM_Processor.py
@@ -12,7 +12,7 @@ class HRM_Processor:
                     file and created and output_dict with the relevant data
                     for the HRM_Processor
         """
-
+        self.csv_file = DataReader.csv_file_path
         self.input_data = DataReader.output_dict
         self.output_dict = {}
         self.write_outputs_to_dict()

The DataWriter needs to be able to write information from the HRM_Processor to a JSON file.
diff --git a/test_DataWriter.py b/test_DataWriter.py
index bf9cc37..49f1785 100644
--- a/test_DataWriter.py
+++ b/test_DataWriter.py
@@ -1,6 +1,48 @@
 from DataWriter import DataWriter
+import json
 
 
 def test_DataWriter_init(hrm):
+    """Tests the initialization of the DataWriter object, and that it
+    successfully gets the output_dict from the input_dict and stores it as
+    metrics.
+
+    Parameters
+    ----------
+    hrm:    HRM_Processor
+            Generic HRM_Procesor made from test_file.csv
+
+    Returns
+    -------
+    None
+
+    """
     dw = DataWriter(hrm)
     assert dw.metrics == hrm.output_dict
+
+
+def test_write_to_json(hrm):
+    """Tests the write_to_json function of the DataWriter, which should be
+    able to take in an dictionary and output file path, and write that
+    dictionary to the specified output file.
+
+    Parameters
+    ----------
+    hrm:    HRM_Processor
+            A generic HRM_Processor made from test_file.csv
+
+    Returns
+    -------
+    None
+    """
+
+    dw = DataWriter(hrm)
+    metrics = {"test": 5,
+               "another word": 18.5}
+    output_file = "test.json"
+    dw.write_to_json(metrics, output_file)
+
+    with open(output_file) as infile:
+        written_data = json.load(infile)
+
+    assert written_data == metrics

pip install -r requirements.txt
parse_log_pytest
requirements.txt
pytest
3.9
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
coverage==7.8.0
exceptiongroup==1.2.2
execnet==2.1.1
iniconfig==2.1.0
numpy==2.0.2
packaging==24.2
pep8==1.7.1
pluggy==1.5.0
pytest==8.3.5
pytest-cache==1.0
pytest-cov==6.0.0
pytest-pep8==1.0.6
tomli==2.2.1

name: bme590hrm
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - coverage==7.8.0
      - exceptiongroup==1.2.2
      - execnet==2.1.1
      - iniconfig==2.1.0
      - numpy==2.0.2
      - packaging==24.2
      - pep8==1.7.1
      - pluggy==1.5.0
      - pytest==8.3.5
      - pytest-cache==1.0
      - pytest-cov==6.0.0
      - pytest-pep8==1.0.6
      - tomli==2.2.1
prefix: /opt/conda/envs/bme590hrm

test_DataWriter.py::test_write_to_json
test_DataWriter.py::test_DataWriter_init
HRM_Processor.py DataWriter.py
HRM_Processor.py DataWriter.py