| import json | |
| from typing import List, Dict | |
| def read_json_to_dict_array(file_path: str) -> List[Dict]: | |
| """ | |
| Read a JSON file and convert its content to an array of dictionaries. | |
| :param file_path: Path to JSON file. | |
| :return: Array or dicts. | |
| """ | |
| try: | |
| with open(file_path, 'r', encoding='utf-8') as f: | |
| data = json.load(f) | |
| if isinstance(data, list): | |
| return data | |
| else: | |
| raise ValueError(f"Wrong data type. Expected list. Got: {str(type(data))}") | |
| except FileNotFoundError: | |
| print(f"File '{file_path}' not found") | |
| except json.JSONDecodeError as e: | |
| print(f"Failed to decode JSON: {e}") | |
| return [] | |