diff options
Diffstat (limited to 'model/system.go')
-rw-r--r-- | model/system.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/model/system.go b/model/system.go new file mode 100644 index 000000000..c79391cca --- /dev/null +++ b/model/system.go @@ -0,0 +1,34 @@ +// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved. +// See License.txt for license information. + +package model + +import ( + "encoding/json" + "io" +) + +type System struct { + Name string `json:"name"` + Value string `json:"value"` +} + +func (o *System) ToJson() string { + b, err := json.Marshal(o) + if err != nil { + return "" + } else { + return string(b) + } +} + +func SystemFromJson(data io.Reader) *System { + decoder := json.NewDecoder(data) + var o System + err := decoder.Decode(&o) + if err == nil { + return &o + } else { + return nil + } +} |