Implement both JsonMarshaler and JsonUnmarshaler
If a type only defines one-half of the symmetry (e.g. it implements MarshalJSON() but not UnmarshalJSON() ), then that type doesn't satisfy the codec encoding/decoding check and instead codec will not encode or decode the item using the special interface methods.
This commit is contained in:
parent
b96cdc79dc
commit
527f85f8e6
1 changed files with 4 additions and 0 deletions
|
@ -77,6 +77,10 @@ func (d *Doc) MarshalJSON() ([]byte, error) {
|
|||
return json.Marshal(d.Data())
|
||||
}
|
||||
|
||||
func (d *Doc) UnmarshalJSON(data []byte) error {
|
||||
return json.Unmarshal(data, &d.data)
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
func (d *Doc) path(path ...string) (paths []string) {
|
||||
|
|
Loading…
Reference in a new issue