LoadJSONFile loads and validates a JSON file
(filePath string, target any)
| 13 | |
| 14 | // LoadJSONFile loads and validates a JSON file |
| 15 | func LoadJSONFile(filePath string, target any) error { |
| 16 | data, err := os.ReadFile(filePath) |
| 17 | if err != nil { |
| 18 | return fmt.Errorf("failed to read file: %w", err) |
| 19 | } |
| 20 | |
| 21 | if err := json.Unmarshal(data, target); err != nil { |
| 22 | return fmt.Errorf("invalid JSON format: %w", err) |
| 23 | } |
| 24 | |
| 25 | return nil |
| 26 | } |
| 27 | |
| 28 | // SaveJSONFile saves data to a JSON file with proper formatting |
| 29 | func SaveJSONFile(filePath string, data any) error { |