https://github.com/ronnygunawan/protobuf-converters
Use Protobuf generated classes in System.Text.Json or MessagePack serialization.
https://github.com/ronnygunawan/protobuf-converters
grpc json messagepack protobuf signalr
Last synced: 9 months ago
JSON representation
Use Protobuf generated classes in System.Text.Json or MessagePack serialization.
- Host: GitHub
- URL: https://github.com/ronnygunawan/protobuf-converters
- Owner: ronnygunawan
- License: mit
- Created: 2021-10-07T09:20:24.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-02-05T17:31:31.000Z (over 4 years ago)
- Last Synced: 2025-07-24T07:51:05.133Z (11 months ago)
- Topics: grpc, json, messagepack, protobuf, signalr
- Language: C#
- Homepage:
- Size: 53.7 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# RG.ProtobufConverters.Json
[](https://www.nuget.org/packages/RG.ProtobufConverters.Json/) [](https://github.com/ronnygunawan/protobuf-converters/actions/workflows/dotnet.yml)
Use Protobuf generated classes in System.Text.Json serialization.
```cs
// Serialize to json
string json = foo.SerializeToJson();
// Deserialize from json
FooMessage? foo = json.DeserializeToProtobufMessage();
```
## Use Protobuf classes in SignalR
Configure hub:
```cs
services.AddSignalR()
.AddJsonProtocol(options => options.PayloadSerializerOptions = ProtobufJsonConverter.Options);
```
Configure client:
```cs
var connection = new HubConnectionBuilder()
.WithUrl("https://yoururl/yourhub")
.AddJsonProtocol(options => options.PayloadSerializerOptions = ProtobufJsonConverter.Options)
.Build();
```
---
# RG.ProtobufConverters.MessagePack
[](https://www.nuget.org/packages/RG.ProtobufConverters.MessagePack/) [](https://github.com/ronnygunawan/protobuf-converters/actions/workflows/dotnet.yml)
```cs
// Serialize to MessagePack bytes
byte[] bytes = foo.SerializeUsingMessagePack();
// Deserialize from MessagePack bytes
FooMessage? foo = bytes.DeserializeUsingMessagePack();
```
## Use Protobuf classes in SignalR
Configure hub:
```cs
services.AddSignalR()
.AddMessagePackProtocol(options => options.SerializerOptions = ProtobufResolver.Options);
```
Configure client:
```cs
var connection = new HubConnectionBuilder()
.WithUrl("https://yoururl/yourhub")
.AddMessagePackProtocol(options => options.SerializerOptions = ProtobufResolver.Options)
.Build();
```