Skip to content

Unmarshaling relationship data that is the JSON literal null does not set a nil pointer #63

Closed
@tracli

Description

@tracli

Describe the bug

Unmarshaling a relationship with data that is the JSON literal null does not set a nil pointer. Instead, it appears that unmarshaling a relationship with null data does not set the value at all. It just so happens that the majority of time, the value we unmarshal into is already nil.

Expected behavior

When unmarshaling a relationship with null data into an interface, map, pointer, or slice, I would expect the value to be nil, even if it was previously non nil. This is how the json package behaves.

From the description of the 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."

Links

An example demonstrating this behavior on go playground: https://go.dev/play/p/Zm06FTE82-D

Additional context

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions