mirror of
https://github.com/daeuniverse/dae.git
synced 2024-12-22 22:25:00 +07:00
feat(config): support IgnoreZero option for config.Marhsaller (#153)
This commit is contained in:
parent
029849da5d
commit
6458ebd877
@ -38,6 +38,7 @@ func (c *Config) Marshal(indentSpace int) (b []byte, err error) {
|
||||
|
||||
type Marshaller struct {
|
||||
IndentSpace int
|
||||
IgnoreZero bool
|
||||
buf bytes.Buffer
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user