Class JsonExporter

java.lang.Object
com.digitizer.io.JsonExporter

public class JsonExporter extends Object
Handles JSON import and export of graph digitizer projects.

The JSON format contains project metadata (title and axis labels), calibration settings (numeric ranges and log flags) and the complete list of datasets and their points. The export path is compatible with the ProjectJson model.

  • Method Details

    • exportToJson

      public static void exportToJson(String filePath, String title, String xlabel, String ylabel, CalibrationState calibration, List<Dataset> datasets) throws IOException
      Exports project data to a JSON file.
      Parameters:
      filePath - the path where the JSON file will be written
      title - the project title
      xlabel - the x-axis label
      ylabel - the y-axis label
      calibration - the calibration state (may be null; defaults applied if null)
      datasets - the list of datasets to export
      Throws:
      IOException - if writing to the file fails
    • importFromJson

      public static ProjectJson importFromJson(String filePath) throws IOException
      Imports project data from a JSON file.
      Parameters:
      filePath - the path to the JSON file to read
      Returns:
      a ProjectJson object containing the imported data
      Throws:
      IOException - if reading from the file fails
      com.google.gson.JsonSyntaxException - if the JSON is malformed
    • convertJsonToDatasets

      public static List<Dataset> convertJsonToDatasets(ProjectJson project, CalibrationState calibration)
      Converts imported JSON data back into application objects.
      Parameters:
      project - the ProjectJson object imported from file
      calibration - the CalibrationState to populate
      Returns:
      a list of Dataset objects