2022-07-25 12:55:59 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"encoding/json"
|
|
|
|
|
"fmt"
|
|
|
|
|
"os"
|
|
|
|
|
)
|
|
|
|
|
|
2022-08-23 14:52:06 +01:00
|
|
|
func loadJSON(file string) (WeatherAPI, error) {
|
2022-07-25 12:55:59 +01:00
|
|
|
var config WeatherAPI
|
|
|
|
|
configFile, err := os.Open(file)
|
|
|
|
|
if err != nil {
|
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
|
}
|
2022-08-23 14:52:06 +01:00
|
|
|
|
2022-07-25 12:55:59 +01:00
|
|
|
jsonParser := json.NewDecoder(configFile)
|
|
|
|
|
jsonParser.Decode(&config)
|
|
|
|
|
return config, err
|
2022-09-03 13:46:41 +01:00
|
|
|
|
2022-07-25 12:55:59 +01:00
|
|
|
}
|