MCPcopy Create free account
hub / github.com/Done-0/gin-scaffold / LoadJSONFile

Function LoadJSONFile

internal/utils/file/json_utils.go:15–26  ·  view source on GitHub ↗

LoadJSONFile loads and validates a JSON file

(filePath string, target any)

Source from the content-addressed store, hash-verified

13
14// LoadJSONFile loads and validates a JSON file
15func 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
29func SaveJSONFile(filePath string, data any) error {

Callers 1

GetTemplateMethod · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected