Skip to content

jsonpb: bring back old behaviour of handling nulls and JSONPBUnmarshaler #1301

Closed
@krzysztofdrys

Description

@krzysztofdrys

What version of protobuf and what language are you using?
go version go1.16.2 darwin/amd64
v1.5.1

What did you do?
We are using a field with a message, which implements jsonpb. JSONPBUnmarshaler to implement NullValue like behaviour for our own messages. This is very similar to the old behaviour of TestUnmarshalNullWithJSONPBUnmarshaler (pre: cc376d7)

What did you expect to see?
When I receive null json value in a nested field, which implements jsonpb. JSONPBUnmarshaler, I expect UnmarshalJSONPB to be called.

I other words, I expect test TestUnmarshalNullWithJSONPBUnmarshaler in form pre cc376d7 to pass.

What did you see instead?

nil is assigned to this field.

I am aware that some breaking changes in similar area have been announced: https://github.com/golang/protobuf/releases#v1.4-nil-values But from what I understand, these release notes are about changes in handling nil go structures, whereas my change is about handling null json elements.

I created a pull request which resolves this issue #1300

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions