Skip to content
Browse files

delete nil values

  • Loading branch information...
1 parent 4f73b7d commit 460586901af6a10e9310bcf0667a777114c3cc49 @fabiokung committed Sep 12, 2012
Showing with 8 additions and 2 deletions.
  1. +8 −2 json.go
View
10 json.go
@@ -104,15 +104,21 @@ type UpdateItemRequest struct {
}
type Attribute struct {
- Value Field
+ Value Field `json:",omitempty"`
+ Action string `json:",omitempty"`
}
func valuesToAttributeMap(item map[string]interface{}) (map[string]Attribute, error) {
attrs := make(map[string]Attribute, len(item))
for n, v := range item {
+ if v == nil {
+ attrs[n] = Attribute{Action: "DELETE"}
+ continue
+ }
+
f, err := NewField(v)
if err != nil {
- return nil, err
+ return attrs, err
}
attrs[n] = Attribute{Value: f}

0 comments on commit 4605869

Please sign in to comment.
Something went wrong with that request. Please try again.