Browse Source

Allow nil maps.

nicerobot 9 years ago
parent
commit
fd5b0a06a7
1 changed files with 4 additions and 0 deletions
  1. 4 0
      marshal.go

+ 4 - 0
marshal.go

@@ -1255,6 +1255,10 @@ func marshalMap(info TypeInfo, value interface{}) ([]byte, error) {
 		return nil, marshalErrorf("marshal: can not marshal none collection type into map")
 	}
 
+	if value == nil {
+		return nil, nil
+	}
+
 	rv := reflect.ValueOf(value)
 	if rv.IsNil() {
 		return nil, nil