Skip to content

Commit

Permalink
feat(config): support IgnoreZero option for config.Marhsaller (daeuni…
Browse files Browse the repository at this point in the history
  • Loading branch information
mzz2017 authored and Markson committed Jun 26, 2023
1 parent 3905f9b commit 46c2b34
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion config/marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func (c *Config) Marshal(indentSpace int) (b []byte, err error) {

type Marshaller struct {
IndentSpace int
IgnoreZero bool
buf bytes.Buffer
}

Expand Down Expand Up @@ -138,7 +139,7 @@ unsupported:
}

func (m *Marshaller) marshalLeaf(key string, from reflect.Value, depth int) (err error) {
if from.IsZero() {
if m.IgnoreZero && from.IsZero() {
// Do not marshal zero value.
return nil
}
Expand Down

0 comments on commit 46c2b34

Please sign in to comment.