Skip to content

Conversation

@neal
Copy link
Contributor

@neal neal commented Jan 9, 2025

#407 fixed the issue where an explicit null field did not reset the value, but a regression was introduced where previously it skipped any null values for non-pointer fields, that now returns an error.

This PR adds a IsNull() check before each unmarshal and the result is the same behavior as I see with stdlib now.

eg. stdlib ignores any null values for non-pointer fields: https://goplay.tools/snippet/dEJi7819RKc

The updated unit test also validates this behavior.

Without this change, the updated test fails to unmarshal:

--- FAIL: TestUnmarshalNull (0.00s)
    basic_test.go:341: easyjson.Unmarshal() error: parse error: expected string near offset 14 of 'String'
    basic_test.go:345: Wanted "bla", got ""
    basic_test.go:349: Wanted nil, got "bla"

@rvasily rvasily merged commit fe2707c into mailru:master Jan 11, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants