-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
encoding/json, encoding/xml: option to treat unknown fields as an error #6901
Comments
I would also like to see this, as well as a path to the field(s) that were not unmarshalled Something like this maybe? type UnmarshalResult struct { Path string //"foo>bar" Unmarshalled bool } func xml.UnmashalWithResult(xmlBytes []byte, v interface{}) []*UnmarshalResult Adding this method rather than modifying the existing Unmarshal method should keep backwards compatibility as well as provide us with this most useful feature |
Additionally, using `xml:ALL` option is not viable for large and living xml documents. Placing a catchall on the root of the element will only work if the entire child element was missed: See foo>c>c2 not showing up as a missed field: http://play.golang.org/p/g3KPa3g4Dm |
I have forked this package and added this functionality while keep backwards compatibility (not fully tested) https://github.com/KyleWolfe/xmlkeys |
One way to do this would be to add a |
I have a simple patch for this for json #10134 |
We should do this. Today, I'm aware of two workarounds:
Besides some way to change the decoder "mode" (as @adg suggested), here's another way it could work: add a |
Closing this in favor of #15314, which is identical and more active. |
The text was updated successfully, but these errors were encountered: