go icon indicating copy to clipboard operation
go copied to clipboard

Support returning non-critical warnings when decoding

Open luxas opened this issue 4 years ago • 0 comments

Hi! Thanks for this great project :1st_place_medal: :100:

When decoding JSON, sometimes you just want to inform the users about problems in the serialized content, rather than returning an error or staying silent. I realize that the Attachment field of https://pkg.go.dev/github.com/json-iterator/go#Iterator could be used for this purpose (thanks for adding that in advance!) by a custom warning-supporting decoder, but it would be nice to add this field specifically for this purpose, so it could be re-used more generally.

The two main uses I see for it would be to warn instead of error when there are duplicate or unknown fields when decoding. I can make a PR with this change if accepted. Would you be open to this?

luxas avatar Aug 30 '21 14:08 luxas