You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The v1 API's jsonpb package checks for custom MarshalJSONPB and UnmarshalJSONPB methods on the type being operated on, and use it when present.
The v2 API should preserve this behaviour, or at least provide an alternative mechanism to customise the behaviour of the marshaller/unmarshaller with respect to a nominated message type.
The text was updated successfully, but these errors were encountered:
The v2 protojson API is meant to follow the Protobuf JSON spec, and the spec does not allow for custom serialization.
Adding the JSONPBMarshaler and JSONPBUnmarshaler at the time #325 was a way to support dynamic messages in JSON serialization.
v2 serialization supports dynamic messages that implement the protoreflect API. It does not allow for custom JSON output/input as it still needs to make sure it abides by the spec.
The magic methods existed to support message implementations other than generated messages. In v2, this becomes unnecessary as all messages are required to implement protobuf reflection moving forward.
alternative mechanism to customise the behaviour of the marshaller/unmarshaller with respect to a nominated message type.
The v1 documentation explicitly says that implementations must properly follow the protobuf JSON specification. These methods were never intended for custom behavior.
The v1 API's jsonpb package checks for custom MarshalJSONPB and UnmarshalJSONPB methods on the type being operated on, and use it when present.
The v2 API should preserve this behaviour, or at least provide an alternative mechanism to customise the behaviour of the marshaller/unmarshaller with respect to a nominated message type.
The text was updated successfully, but these errors were encountered: