diff --git a/json.go b/json.go new file mode 100644 index 0000000..ddb7ee6 --- /dev/null +++ b/json.go @@ -0,0 +1,18 @@ +package main + +import ( + "encoding/json" + "fmt" + "os" +) + +func loadJson(file string) (WeatherAPI, error) { + var config WeatherAPI + configFile, err := os.Open(file) + if err != nil { + fmt.Println(err.Error()) + } + jsonParser := json.NewDecoder(configFile) + jsonParser.Decode(&config) + return config, err +}