This commit is contained in:
Stash Dev
2019-02-14 15:42:52 -08:00
parent 1d00b2b36f
commit b488c1ed7d
111 changed files with 141 additions and 141 deletions

View File

@@ -0,0 +1,35 @@
package jsonschema
import (
"encoding/json"
"fmt"
"os"
)
type Studio struct {
Name string `json:"name,omitempty"`
URL string `json:"url,omitempty"`
Image string `json:"image,omitempty"`
}
func LoadStudioFile(filePath string) (*Studio, error) {
var studio Studio
file, err := os.Open(filePath)
defer file.Close()
if err != nil {
return nil, err
}
jsonParser := json.NewDecoder(file)
err = jsonParser.Decode(&studio)
if err != nil {
return nil, err
}
return &studio, nil
}
func SaveStudioFile(filePath string, studio *Studio) error {
if studio == nil {
return fmt.Errorf("studio must not be nil")
}
return marshalToFile(filePath, studio)
}