Przeglądaj źródła

Added Object.UnmarshalJSON

Dmitry Panov 3 lat temu
rodzic
commit
09250e0eba
1 zmienionych plików z 7 dodań i 0 usunięć
  1. 7 0
      value.go

+ 7 - 0
value.go

@@ -935,6 +935,13 @@ func (o *Object) MarshalJSON() ([]byte, error) {
 	return ctx.buf.Bytes(), nil
 }
 
+// UnmarshalJSON implements the json.Unmarshaler interface. It is added to compliment MarshalJSON, because
+// some alternative JSON encoders refuse to use MarshalJSON unless UnmarshalJSON is also present.
+// It is a no-op and always returns nil.
+func (o *Object) UnmarshalJSON([]byte) error {
+	return nil
+}
+
 // ClassName returns the class name
 func (o *Object) ClassName() string {
 	return o.self.className()