aboutsummaryrefslogtreecommitdiff
path: root/src/encoding/json/encode.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/encoding/json/encode.go')
-rw-r--r--src/encoding/json/encode.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/encoding/json/encode.go b/src/encoding/json/encode.go
index 578d551102..8e6b342b59 100644
--- a/src/encoding/json/encode.go
+++ b/src/encoding/json/encode.go
@@ -245,6 +245,12 @@ func (e *UnsupportedValueError) Error() string {
return "json: unsupported value: " + e.Str
}
+// Is returns true if target is a UnsupportedValueError.
+func (e *UnsupportedValueError) Is(target error) bool {
+ _, ok := target.(*UnsupportedValueError)
+ return ok
+}
+
// Before Go 1.2, an InvalidUTF8Error was returned by Marshal when
// attempting to encode a string value with invalid UTF-8 sequences.
// As of Go 1.2, Marshal instead coerces the string to valid UTF-8 by
@@ -279,6 +285,12 @@ func (e *MarshalerError) Error() string {
// Unwrap returns the underlying error.
func (e *MarshalerError) Unwrap() error { return e.Err }
+// Is returns true if target is a MarshalerError.
+func (e *MarshalerError) Is(target error) bool {
+ _, ok := target.(*MarshalerError)
+ return ok
+}
+
var hex = "0123456789abcdef"
// An encodeState encodes JSON into a bytes.Buffer.