Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 3 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 3 years ago)
- Default Branch: master
- Last Pushed: 2022-02-05T17:31:31.000Z (about 3 years ago)
- Last Synced: 2024-11-11T13:11:55.579Z (3 months ago)
- Topics: grpc, json, messagepack, protobuf, signalr
- Language: C#
- Homepage:
- Size: 53.7 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# RG.ProtobufConverters.Json
[![NuGet](https://img.shields.io/nuget/v/RG.ProtobufConverters.Json.svg)](https://www.nuget.org/packages/RG.ProtobufConverters.Json/) [![.NET](https://github.com/ronnygunawan/protobuf-converters/actions/workflows/dotnet.yml/badge.svg)](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
[![NuGet](https://img.shields.io/nuget/v/RG.ProtobufConverters.MessagePack.svg)](https://www.nuget.org/packages/RG.ProtobufConverters.MessagePack/) [![.NET](https://github.com/ronnygunawan/protobuf-converters/actions/workflows/dotnet.yml/badge.svg)](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();
```