Browse Source

Merge pull request #780 from Spatially/master

Allow nil lists.
Chris Bannister 9 years ago
parent
commit
58b3c7120a
2 changed files with 5 additions and 0 deletions
  1. 1 0
      AUTHORS
  2. 4 0
      marshal.go

+ 1 - 0
AUTHORS

@@ -78,3 +78,4 @@ Mark M <m.mim95@gmail.com>
 Bartosz Burclaf <burclaf@gmail.com>
 Marcus King <marcusking01@gmail.com>
 Andrew de Andrade <andrew@deandrade.com.br>
+Robert Nix <robert@nicerobot.org>

+ 4 - 0
marshal.go

@@ -1143,6 +1143,10 @@ func marshalList(info TypeInfo, value interface{}) ([]byte, error) {
 		return nil, marshalErrorf("marshal: can not marshal non collection type into list")
 	}
 
+	if value == nil {
+		return nil, nil
+	}
+
 	rv := reflect.ValueOf(value)
 	t := rv.Type()
 	k := t.Kind()