ProtoBufJsonConverter 0.0.4

ProtoBufJsonConverter

This project uses protobuf-net to:

  • Convert a protobuf message to a JSON string using the proto definition file.
  • Convert a protobuf message to an object using the proto definition file.
  • Convert a JSON string or an object to a protobuf message using the proto definition file.

Usage

Proto Definition

syntax = "proto3";

// Package name
package greet;

// The greeting service definition.
service Greeter {
  rpc SayHello (HelloRequest) returns (HelloReply);
}

// The request message containing the user's name.
message HelloRequest {
  string name = 1;
}

// The response message containing the greetings
message HelloReply {
  string message = 1;
}

:one: Convert ProtoBuf byte[] to a JSON string

Code

var protoDefinition = "...". // See above

var bytes = Convert.FromBase64String("CgRzdGVm");

var request = new ConvertToJsonRequest(protoDefinition, "greet.HelloRequest", bytes);

var converter = new Converter();

var json = converter.Convert(request);

JSON

{"name":"stef"}

:one: Convert ProtoBuf byte[] to an object

Code

var protoDefinition = "...". // See above

var bytes = Convert.FromBase64String("CgRzdGVm");

var request = new ConvertToObjectRequest(protoDefinition, "greet.HelloRequest", bytes);

var converter = new Converter();

var @object = converter.Convert(request);

:three: Convert JSON string to a ProtoBuf byte[]

Code

var protoDefinition = "...". // See above

var json = @"{""name"":""stef""}";

var request = new ConvertToProtoBufRequest(protoDefinition, "greet.HelloRequest", json);

var converter = new Converter();

var protobuf = converter.Convert(request);

:four: Convert any object to a ProtoBuf byte[]

Code

var protoDefinition = "...". // See above

var obj = new
{
    name = "stef"
};

var request = new ConvertToProtoBufRequest(protoDefinition, "greet.HelloRequest", obj);

var converter = new Converter();

var protobuf = converter.Convert(request);

Showing the top 20 packages that depend on ProtoBufJsonConverter.

Packages Downloads
WireMock.Net
Lightweight Http Mocking Server for .Net, inspired by WireMock from the Java landscape.
22
WireMock.Net.ProtoBuf
ProtoBuf and gRPC support for WireMock.Net
18
WireMock.Net
Lightweight Http Mocking Server for .Net, inspired by WireMock from the Java landscape.
16
WireMock.Net.ProtoBuf
ProtoBuf and gRPC support for WireMock.Net
15
WireMock.Net
Lightweight Http Mocking Server for .Net, inspired by WireMock from the Java landscape.
15
WireMock.Net
Lightweight Http Mocking Server for .Net, inspired by WireMock from the Java landscape.
14
WireMock.Net.ProtoBuf
ProtoBuf and gRPC support for WireMock.Net
14
WireMock.Net.Minimal
Minimal version from the lightweight Http Mocking Server for .NET
14

See CHANGELOG.md

Version Downloads Last updated
0.11.0 21 09/30/2026
0.10.0.1 17 10/01/2026
0.10.0 14 10/01/2026
0.9.0 14 10/01/2026
0.8.0 16 10/01/2026
0.8.0-preview-01 15 10/01/2026
0.7.0 13 10/01/2026
0.7.0-preview-02 19 10/01/2026
0.7.0-preview-01 16 10/01/2026
0.6.0 15 10/01/2026
0.6.0-preview-03 13 10/01/2026
0.6.0-preview-02 16 10/01/2026
0.6.0-preview-01 14 10/01/2026
0.5.0 15 10/01/2026
0.4.0 13 10/01/2026
0.3.0 15 10/01/2026
0.2.0 18 10/01/2026
0.1.0 16 10/01/2026
0.0.6 15 10/01/2026
0.0.5 14 10/01/2026
0.0.4 12 10/01/2026
0.0.3 15 10/01/2026
0.0.2 16 10/01/2026