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
Describe the problem you are trying to solve.
Trying to introduce custom json output formatting for specific types that are autogenerated from protobuf definitions using the JsonFormat class
Currently only default serialization is possible, not allowing any custom printers to be added.
Describe the solution you'd like
ability to add additional custom printers for types that would allow custom Json output value formatting
Describe alternatives you've considered
We have used similar functionality with the scalpb-json4s library that allows us to override the printer for certain types using the DefaultRegistry
The text was updated successfully, but these errors were encountered:
It is not clear from your question how customization of JSON serialization would work given the need for the JSON to be parseable back into a Proto by a client in another language, or even within Java if they have a different set of customizations. Whereas text formatting is fairly customizable, it is not intended for exchange. JSON has to be able to roundtrip.
Maybe you could provide an example of the kind of customization you need?
What language does this apply to?
proto3
Describe the problem you are trying to solve.
Trying to introduce custom json output formatting for specific types that are autogenerated from protobuf definitions using the JsonFormat class
Currently only default serialization is possible, not allowing any custom printers to be added.
Describe the solution you'd like
ability to add additional custom printers for types that would allow custom Json output value formatting
Example of printers being added in the code currently:
https://github.com/protocolbuffers/protobuf/blob/main/java/util/src/main/java/com/google/protobuf/util/JsonFormat.java#L750
And the wellKnownTypePrinters is private which does not allow extensions:
https://github.com/protocolbuffers/protobuf/blob/main/java/util/src/main/java/com/google/protobuf/util/JsonFormat.java#L747
It would be helpful to allow serialization of enums according to custom rules. Currently it appears this is fixed and no override is possible:
https://github.com/protocolbuffers/protobuf/blob/main/java/util/src/main/java/com/google/protobuf/util/JsonFormat.java#L1234
Describe alternatives you've considered
We have used similar functionality with the scalpb-json4s library that allows us to override the printer for certain types using the DefaultRegistry
The text was updated successfully, but these errors were encountered: