encoding/json: fails to ignore fields with more than one ignore tag #26062
Labels
Comments
Try using a space to separate the struct tags instead of a comma. See https://golang.org/pkg/reflect/#StructTag. |
This is another illustration of how confusing unstructured tags are: #23637 |
The code works as expected when using spaces to separate tags. https://play.golang.org/p/0Fa7VU60y0G |
Thanks @josharian & @FiloSottile, didn't realise it had to be spaces, thanks for the doc references as well! |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes. I can replicate this with
go1.10.3 linux/amd64
andgo1.10.2 windows/amd64
.What operating system and processor architecture are you using (
go env
)?What did you do?
What did you expect to see?
All four use cases should work. Struct field tags denoted by
"-"
should be ignored by all marshallers.What did you see instead?
My use case is having types pull double-duty as both MongoDB objects as well as JSON objects, but I want to be able to ignore unsupported types, such as channels, with struct tags and have both struct tags be ignored properly.
The text was updated successfully, but these errors were encountered: