Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
encoding/json: decoding a null value does not replace previous value #14640
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:
However, if the decoded value is null the previous value is not replaced.
Example of incorrect behaviour:
Is this intended behaviour for
Additionally, if this is intended behaviour the
A fixed version without possibility of incorrect results: http://play.golang.org/p/zVM9xzqIz4
I believe this is working as intended and documented.
Example without a struct: https://play.golang.org/p/MmRj0E1bvV
If your struct has one of the nullable types mentioned above, such as a pointer, then unmarshaling