proposal: encoding/json: add options to allow marshalling of ignored JSON fields #29426
Labels
Milestone
Comments
See my comment here about my concern with the proliferation of top-level |
Sorry, ignored means ignored. Otherwise we need a "really ignored" for when you're printing the things that are only "kind of ignored". Like exit vs atexit vs quick_exit vs at_quick_exit in C/C++. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Sometimes I find myself wanting to marshal and unmarshal ignored JSON fields (in the general case they should be ignored, but in certain cases they shouldn't). All ways I've come up with to get around this limitation feel kind of clunky, I try very hard to avoid reflection when I can. Feel free to correct me if there is a better solution out there already.
What version of Go are you using (
go version
)?Suggestion
It would be cool if we could embed structs and then cast them, as such:
I'm guessing it could potentially be solved at compile time by substituting the embedded field with the overriding field, while maintaining the order of the fields in the struct.
Another option would be to add options to the JSON marshaller, where one could be to ignore ignored fields. What do you guys think?
The text was updated successfully, but these errors were encountered: