Golang encoding/json.Unmarshaler type example

encoding/json

Unmarshaler is the interface implemented by objects that can unmarshal a JSON description of themselves. The input can be assumed to be a valid encoding of a JSON value. UnmarshalJSON must copy the JSON data if it wishes to retain the data after returning.

Golang encoding/json.Unmarshaler type usage example

 type Cmd interface {
  json.Marshaler
  json.Unmarshaler // <-- here
  Id() interface{}
  Method() string
 }

Reference :

http://golang.org/pkg/encoding/json/#Unmarshaler

Advertisement