encoding/json, encoding/xml: option to treat unknown fields as an error #6901
Labels
Milestone
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. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: