Explorar el Código

Allow nil maps.

nicerobot hace 9 años
padre
commit
fd5b0a06a7
Se han modificado 1 ficheros con 4 adiciones y 0 borrados
  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