encoding/json: decoding a null value does not replace previous value #14640
Labels
Documentation
FrozenDueToAge
NeedsFix
The path to resolution is known, but the work has not been done.
Milestone
Decoding a JSON value into an already populated struct replaces the previous value stored in the struct as long as the key is present.
Example of working behaviour:
http://play.golang.org/p/pGaGDSbVMy
However, if the decoded value is null the previous value is not replaced.
Example of incorrect behaviour:
http://play.golang.org/p/i25WkqFrW-
Is this intended behaviour for
json.Unmarshal
,json.Decoder.Decode
& co.?Additionally, if this is intended behaviour the
json.Decoder.Decode
example at golang.org might need fixing. It currently shows the following example which will exhibit incorrect results if eitherName
orText
is null: http://play.golang.org/p/wfoi8On0DXA fixed version without possibility of incorrect results: http://play.golang.org/p/zVM9xzqIz4
Go version:
go version go1.6 linux/amd64
Go environment:
The text was updated successfully, but these errors were encountered: