Skip to content

Excluding known typed fields from returned map #16

Closed
@thedenisnikulin

Description

@thedenisnikulin

It would be great if there was an option that excludes from resulting map[string]interface{} the fields that were unmarshalled to the struct object, see the example below:

v := struct {
	Foo string `json:"foo"`
	Boo []int  `json:"boo"`
}{}
result, err := marshmallow.Unmarshal([]byte(`{"foo":"bar","boo":[1,2,3],"goo":12.6}`), &v)
fmt.Printf("v=%+v, result=%+v, err=%v", v, result, err)
// Output: v={Foo:bar Boo:[1 2 3]}, result=map[goo:12.6], err=<nil>
//                                  ^^^^^^     ^^^
// only "goo" field is present in result since "foo" and "boo" are explicitly typed

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions