Class JsonImporter

java.lang.Object
utils.JsonImporter

public class JsonImporter extends Object
Utilities to import project metadata from JSON files.

The expected JSON format is an array of objects where each object contains fields such as `id`, `name`, `project_type`, `file_path`, `description` and `created_date`.

Example file content:
[ { "id": 1, "name": "Box", "file_path": "/tmp/box", "description": "..." } ]
  • Constructor Details

    • JsonImporter

      private JsonImporter()
      Private constructor to prevent instantiation of this utility class.
  • Method Details

    • importProjects

      public static List<Map<String,Object>> importProjects(String filePath) throws IOException, org.json.JSONException
      Read a JSON array of projects and return a list of maps with the extracted fields.
      Parameters:
      filePath - path to JSON file
      Returns:
      list of project maps
      Throws:
      IOException - when file cannot be read
      org.json.JSONException - when parsing fails or expected keys are missing
    • validateJsonStructure

      public static boolean validateJsonStructure(String filePath)
      Quick validation that the file contains a JSON array. Returns false on any parse or IO error.
      Parameters:
      filePath - path to validate
      Returns:
      true when the file contains a parsable JSON array
    • importProjectsFromJsonFile

      public static List<Map<String,Object>> importProjectsFromJsonFile(String filePath) throws IOException, org.json.JSONException
      Backwards-compatible wrapper expected by tests and callers. Delegates to importProjects(String).
      Parameters:
      filePath - path to JSON file
      Returns:
      list of project maps
      Throws:
      IOException - when file cannot be read
      org.json.JSONException - when parsing fails