]> Cypherpunks repositories - gostls13.git/commit
encoding/json: disallow unknown fields in Decoder
authorIvan Bertona <ivan.bertona@gmail.com>
Tue, 31 Oct 2017 20:16:38 +0000 (13:16 -0700)
committerJoe Tsai <thebrokentoaster@gmail.com>
Tue, 31 Oct 2017 22:28:36 +0000 (22:28 +0000)
commit2596a0c075aeddec571cd658f748ac7a712a2b69
tree7703794a12c402a11fc067d3ca527d96bac658bb
parentd58f4e9b7b503ed83641e2cd632a19011da6b50c
encoding/json: disallow unknown fields in Decoder

Add a DisallowUnknownFields flag to Decoder.

DisallowUnknownFields causes the Decoder to return an error when
the the decoding destination is a struct and the input contains
object keys which do not match any non-ignored, public field the
destination, including keys whose value is set to null.

Note: this fix has already been worked on in 27231, which seems
to be abandoned. This version is a slightly simpler implementation
and is up to date with the master branch.

Fixes #15314

Change-Id: I987a5857c52018df334f4d1a2360649c44a7175d
Reviewed-on: https://go-review.googlesource.com/74830
Reviewed-by: Joe Tsai <joetsai@google.com>
Run-TryBot: Joe Tsai <joetsai@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/encoding/json/decode.go
src/encoding/json/decode_test.go
src/encoding/json/stream.go