{"record":{"id":"9ab7b5265567de1a","repo":"ultralytics/ultralytics","slug":"json-file-path-cannot-be-empty","errorCode":null,"errorMessage":"❌ JSON file path cannot be empty.","messagePattern":"❌ JSON file path cannot be empty\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"ultralytics/solutions/parking_management.py","lineNumber":210,"sourceCode":"\n    Methods:\n        process: Process the input image for parking lot management and visualization.\n\n    Examples:\n        >>> from ultralytics.solutions import ParkingManagement\n        >>> parking_manager = ParkingManagement(model=\"yolo26n.pt\", json_file=\"parking_regions.json\")\n        >>> print(f\"Occupied spaces: {parking_manager.pr_info['Occupancy']}\")\n        >>> print(f\"Available spaces: {parking_manager.pr_info['Available']}\")\n    \"\"\"\n\n    def __init__(self, **kwargs: Any) -> None:\n        \"\"\"Initialize the parking management system with a YOLO model and visualization settings.\"\"\"\n        super().__init__(**kwargs)\n\n        self.json_file = self.CFG[\"json_file\"]  # Load parking regions JSON data\n        if not self.json_file:\n            LOGGER.warning(\"ParkingManagement requires `json_file` with parking region coordinates.\")\n            raise ValueError(\"❌ JSON file path cannot be empty.\")\n\n        with open(self.json_file, encoding=\"utf-8\") as f:\n            self.json = json.load(f)\n\n        self.pr_info = {\"Occupancy\": 0, \"Available\": 0}  # Dictionary for parking information\n\n        self.arc = (0, 0, 255)  # Available region color\n        self.occ = (0, 255, 0)  # Occupied region color\n        self.dc = (255, 0, 189)  # Centroid color for each box\n\n    def process(self, im0: np.ndarray) -> SolutionResults:\n        \"\"\"Process the input image for parking lot management and visualization.\n\n        This function analyzes the input image, extracts tracks, and determines the occupancy status of parking regions\n        defined in the JSON file. It annotates the image with occupied and available parking spots, and updates the\n        parking information.\n\n        Args:","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/ultralytics/ultralytics/blob/0449ea011cfd6c9a0d50a0bf1043aca5190cd476/ultralytics/solutions/parking_management.py#L192-L228","documentation":"ParkingManagement.__init__ reads json_file from its config (CFG['json_file']) and immediately refuses to continue when it is empty/None: parking regions are the core data structure of this solution, and there is no sensible default. A warning names the missing argument and ValueError follows, so construction fails fast rather than crashing later at process() time.","triggerScenarios":"Instantiating ParkingManagement() without json_file, or with json_file='' / None — e.g. copying the constructor from another solution (ObjectCounter) that needs no JSON and forgetting this one does.","commonSituations":"Adapting example scripts; passing the JSON path under a wrong kwarg name (e.g. json='...') so the real json_file stays empty; config dicts loaded from files missing the json_file key.","solutions":["Create a parking-regions JSON (list of regions with polygon coordinates) and pass ParkingManagement(json_file='parking_regions.json')","Verify the kwarg name is exactly json_file so it lands in CFG","Use the official parking management example JSON structure as the template"],"exampleFix":"# before\nmanager = ParkingManagement(model='yolo26n.pt')  # ValueError\n\n# after\nmanager = ParkingManagement(model='yolo26n.pt', json_file='parking_regions.json')","handlingStrategy":"validation","validationCode":"assert json_file and Path(json_file).is_file(), 'supply an existing parking regions JSON'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prepare and validate the parking-regions JSON before constructing ParkingManagement","Reuse the documented example JSON structure for region coordinates"],"tags":["solutions","parking","config","validation","json"],"backgroundTag":null,"analyzedSha":"0449ea011cfd6c9a0d50a0bf1043aca5190cd476","analyzedAt":"2026-08-15T02:34:13.413Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}