Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Unmarshal json null relationship data to nil #65

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tracli
Copy link

@tracli tracli commented Jan 22, 2025

Fix issue #63

When unmarshaling relationship data that is the json literal null to an interface, map, pointer, or slice, we should set the value to nil. This is different from the current behavior, which is to assume the value is already nil and do nothing. If unmarshaling to any other type, continue to do nothing.

The motivation for this is to match the behavior of the standard library json package: "The JSON null value unmarshals into an interface, map, pointer, or slice by setting that Go value to nil. Because null is often used in JSON to mean “not present,” unmarshaling a JSON null into any other Go type has no effect on the value and produces no error."

When unmarshaling relationship data that is the json literal null to an interface, map, pointer, or slice, set
the value to nil instead of the current behavior, which is to assume the value is already nil and do nothing.
If unmarshaling to any other type, continue to do nothing.
@tracli tracli marked this pull request as ready for review January 22, 2025 15:48
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant