-
Notifications
You must be signed in to change notification settings - Fork 10k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gRPC JSON transcoding / Support custom JsonConverter #46712
Comments
In case someone is interested in a workaround: #50401 (comment) |
This workaround not working with custom converters. Exception appear, after registering custom converter using reflection: |
hello, did you find a solution for that? i can not cast Google.Protobuf.WellKnownTypes. i get this error : Exception was thrown by handler. InvalidCastException: Unable to cast object of type 'Google.Protobuf.WellKnownTypes.StringValue' to type 'System.String'. thank you. |
Are you sure, that you specify 'string?' (nullable)? |
i created new issue : |
Summary
Allow to use custom
JsonConverter
in gRPC JSON transcoding.Motivation and goals
Motivation
decimal
(for example) in protobuf well-known types;units
andnanos
instead ofdecimal
;MapType
;JsonConverter
for REST API;Because of the last point all REST API consumers must write wrappers for
decimal
or you must usestring
fordecimal
.Goals
Add
JsonConverter
support for gRPC JSON transcoding.Valuabiity
decimal
implementation is a common issue which is solved via custom type Decimal Type? protocolbuffers/protobuf#4406;Guid
also Provide support for UUID type (a.k.a. GUID) protocolbuffers/protobuf#2224;grpc-gateway
supports custom marshalers Response body as a single field grpc-ecosystem/grpc-gateway#217.In scope
Out of scope
–
Risks / unknowns
Risks
–
Unknowns
@JamesNK explicitly wrote in gRPC JSON transcoding documentation:
I haven't found decision clarification for this behaviour.
Examples
AddJsonTranscoding
there could be a propertyConverters
where you can add your ownJsonConverter
like inJsonSerializerOptions
;JsonConverter
attribute on a not well-known types.The text was updated successfully, but these errors were encountered: