Permalink
Browse files

handle nil values

  • Loading branch information...
1 parent fca2d5a commit 4f73b7db6edbecd66d6e7f5a39a8b69bbb1ba9fb @fabiokung committed Sep 13, 2012
Showing with 4 additions and 0 deletions.
  1. +4 −0 json.go
View
@@ -72,6 +72,10 @@ func NewField(value interface{}) (Field, error) {
v = v.Elem()
}
+ if !v.IsValid() {
+ return nil, nil
+ }
+
switch v.Kind() {
case reflect.String:
return &String{S: value.(string)}, nil

0 comments on commit 4f73b7d

Please sign in to comment.