Class JsonImporter
java.lang.Object
utils.JsonImporter
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 Summary
ConstructorsModifierConstructorDescriptionprivatePrivate constructor to prevent instantiation of this utility class. -
Method Summary
Modifier and TypeMethodDescriptionimportProjects(String filePath) Read a JSON array of projects and return a list of maps with the extracted fields.importProjectsFromJsonFile(String filePath) Backwards-compatible wrapper expected by tests and callers.static booleanvalidateJsonStructure(String filePath) Quick validation that the file contains a JSON array.
-
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 readorg.json.JSONException- when parsing fails or expected keys are missing
-
validateJsonStructure
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 toimportProjects(String).- Parameters:
filePath- path to JSON file- Returns:
- list of project maps
- Throws:
IOException- when file cannot be readorg.json.JSONException- when parsing fails
-