Skip to content

gRPC JSON transcoding / Support custom JsonConverter #46712

@colotiline

Description

@colotiline

Summary

Allow to use custom JsonConverter in gRPC JSON transcoding.

Motivation and goals

Motivation

Because of the last point all REST API consumers must write wrappers for decimal or you must use string for decimal.

Goals

Add JsonConverter support for gRPC JSON transcoding.

Valuabiity

In scope

  • As a developer I want to implement custom JsonConverter for gRPC JSON transcoding.
  • As a developer I want that gRPC and JSON types could have a different representation for the same .NET type.

Out of scope

Risks / unknowns

Risks

Unknowns

@JamesNK explicitly wrote in gRPC JSON transcoding documentation:

Transcoding doesn't support advanced JSON customization. Apps requiring precise JSON structure control should consider using ASP.NET Core Web API.
https://learn.microsoft.com/en-us/aspnet/core/grpc/json-transcoding-binding?view=aspnetcore-7.0#customize-json

I haven't found decision clarification for this behaviour.

Examples

  • When you AddJsonTranscoding there could be a property Converters where you can add your own JsonConverter like in JsonSerializerOptions;
  • gRPC JSON transcoding also could look for JsonConverter attribute on a not well-known types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-grpcIncludes: GRPC wire-up, templatesdesign-proposalThis issue represents a design proposal for a different issue, linked in the description

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions