mirror of https://github.com/k3s-io/k3s
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
467 B
24 lines
467 B
6 years ago
|
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
|
||
|
}
|