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.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic GrpcJsonMarshallerBuilder
builder()
Returns a newGrpcJsonMarshallerBuilder
.Returns a newGsonGrpcJsonMarshallerBuilder
.<T> T
deserializeMessage
(io.grpc.MethodDescriptor.Marshaller<T> marshaller, InputStream is) Deserializes a gRPC message from JSON.static GrpcJsonMarshaller
of
(io.grpc.ServiceDescriptor serviceDescriptor) Returns a newly-createdGrpcJsonMarshaller
which serializes and deserializes aMessage
served by the service.static GrpcJsonMarshaller
ofGson()
Returns a newly-createdGrpcJsonMarshaller
which serializes and deserializes aMessage
.<T> void
serializeMessage
(io.grpc.MethodDescriptor.Marshaller<T> marshaller, T message, OutputStream os) Serializes a gRPC message into JSON.
-
Method Details
-
of
Returns a newly-createdGrpcJsonMarshaller
which serializes and deserializes aMessage
served 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-createdGrpcJsonMarshaller
which serializes and deserializes aMessage
. This implementation internally uses JsonFormat andGson
to 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 andGson
to 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(io.grpc.MethodDescriptor.Marshaller<T> marshaller, T message, OutputStream os) throws IOException Serializes a gRPC message into JSON.- Throws:
IOException
-
deserializeMessage
<T> T deserializeMessage(io.grpc.MethodDescriptor.Marshaller<T> marshaller, InputStream is) throws IOException Deserializes a gRPC message from JSON.- Throws:
IOException
-