ffjson icon indicating copy to clipboard operation
ffjson copied to clipboard

Add option to unmarshal json in a strict way

Open GeertJohan opened this issue 10 years ago • 1 comments

I would like to add a feature to ffjson, actually I've already implemented the feature in a local fork.

When ffjson is executed with a newly introduced flag -decode-fields-strict, it generates code that errors when a field in the json is not defined in the Go type. This means that unmarshaling {"foo": 42} into type quux struct { Bar int} will fail, as "foo" is not present as a field in the struct. It does not error when a field defined in the Go type is not set in the json (validation of values can/should still be implemented by the user).

If you're interested in this feature, I could open a PR.

GeertJohan avatar Sep 23 '15 07:09 GeertJohan

:+1:

dolmen avatar Oct 22 '15 10:10 dolmen