go-omaha/vendor/github.com/blang/semver/json.go
Stephen Demos e95ad781c1 vendor: vendor glide dependencies
this lets us specify dependencies more specifically and also build
binaries as a part of the project.
2017-12-05 14:46:15 -08:00

23 lines
467 B
Go

package semver
import (
"encoding/json"
)
// MarshalJSON implements the encoding/json.Marshaler interface.
func (v Version) MarshalJSON() ([]byte, error) {
return json.Marshal(v.String())
}
// UnmarshalJSON implements the encoding/json.Unmarshaler interface.
func (v *Version) UnmarshalJSON(data []byte) (err error) {
var versionString string
if err = json.Unmarshal(data, &versionString); err != nil {
return
}
*v, err = Parse(versionString)
return
}