浏览代码

Allow nil maps.

nicerobot 9 年之前
父节点
当前提交
fd5b0a06a7
共有 1 个文件被更改,包括 4 次插入0 次删除
  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