Package com.linecorp.armeria.common.grpc
Interface GrpcJsonMarshaller
public interface GrpcJsonMarshaller
A JSON marshaller for gRPC method request or response messages to and from JSON.
-
Method Summary
Modifier and TypeMethodDescriptionstatic GrpcJsonMarshallerBuilderbuilder()Returns a newGrpcJsonMarshallerBuilder.Returns a newGsonGrpcJsonMarshallerBuilder.<T> TdeserializeMessage(MethodDescriptor.Marshaller<T> marshaller, InputStream is) Deserializes a gRPC message from JSON.static GrpcJsonMarshallerof(ServiceDescriptor serviceDescriptor) Returns a newly-createdGrpcJsonMarshallerwhich serializes and deserializes aMessageserved by the service.static GrpcJsonMarshallerofGson()Returns a newly-createdGrpcJsonMarshallerwhich serializes and deserializes aMessage.<T> voidserializeMessage(MethodDescriptor.Marshaller<T> marshaller, T message, OutputStream os) Serializes a gRPC message into JSON.
-
Method Details
-
of
Returns a newly-createdGrpcJsonMarshallerwhich serializes and deserializes aMessageserved by the service. This implementation internally uses protobuf-jackson to serialize and deserialize messages. -
builder
Returns a newGrpcJsonMarshallerBuilder. This implementation internally uses protobuf-jackson to serialize and deserialize messages. -
ofGson
Returns a newly-createdGrpcJsonMarshallerwhich serializes and deserializes aMessage. This implementation internally uses JsonFormat andGsonto serialize and deserialize messages. Note: JsonFormat has a known performance issue. Use this method only when 1) you're using Protobuf 2 or 2) you have an issue with protobuf-jackson. -
builderForGson
Returns a newGsonGrpcJsonMarshallerBuilder. This implementation internally uses JsonFormat andGsonto serialize and deserialize messages. Note: JsonFormat has a known performance issue. Use this method only when 1) you're using Protobuf 2 or 2) you have an issue with protobuf-jackson. -
serializeMessage
<T> void serializeMessage(MethodDescriptor.Marshaller<T> marshaller, T message, OutputStream os) throws IOException Serializes a gRPC message into JSON.- Throws:
IOException
-
deserializeMessage
<T> T deserializeMessage(MethodDescriptor.Marshaller<T> marshaller, InputStream is) throws IOException Deserializes a gRPC message from JSON.- Throws:
IOException
-