diff --git a/encoder.go b/encoder.go
index 7ab271a..c84344a 100644
--- a/encoder.go
+++ b/encoder.go
@@ -104,9 +104,21 @@ func encodeStruct(structVal reflect.Value) ([]byte, error) {
name = fieldType.Name
}
- p, err := encodeValue(fieldVal)
- if err != nil {
- return nil, err
+ var p []byte
+ var err error
+ // if the tag has the nilTag property, write it as ''
+ if strings.HasSuffix(name, ",nilTag") && fieldVal.IsNil() {
+ p, err = []byte(""), nil
+
+ name = strings.TrimSuffix(name, ",nilTag")
+ if name == "" {
+ name = fieldType.Name
+ }
+ } else {
+ p, err = encodeValue(fieldVal)
+ if err != nil {
+ return nil, err
+ }
}
b.WriteString("")