.. _json: RESTFULL JSON API ================= GRPC ---- For example, define an API like this: .. code-block:: proto message SayHelloRequest { string stringValue = 1; int64 int64Value = 2; } message SayHelloResponse { string message = 1; } service TestService { rpc sayHello (SayHelloRequest) returns (SayHelloResponse) {} } Struct code generated by protobuf: .. code-block:: go type SayHelloRequest struct { StringValue string `protobuf:"bytes,2,opt,name=stringValue" json:"stringValue,omitempty"` Int64Value int64 `protobuf:"varint,3,opt,name=int64Value" json:"int64Value,omitempty"` } Refer to :ref:`How to add a new API `, implement this API. Then, start server, send a POST request(Content-Type=application/json) with a body like this: .. code-block:: json { "stringValue":"a string value", "int64Value":1234 } **NOTE**: The key name in json **MUST** be the same with the name in tag "protobuf". You should be able to get the data in json in your grpc service func. Thrift ------ Similar Example: .. code-block:: thrift struct SayHelloRequest { 1: string stringValue, 2: i32 int32Value, 3: bool boolValue, } struct SayHelloResponse { 1: string message, } service TestService { SayHelloResponse testJson (1:SayHelloRequest request) } Struct code generated by thrift: .. code-block:: go type TestJsonRequest struct { StringValue string `thrift:"stringValue,1" db:"stringValue" json:"stringValue"` Int32Value int32 `thrift:"int32Value,2" db:"int32Value" json:"int32Value"` BoolValue bool `thrift:"boolValue,3" db:"boolValue" json:"boolValue"` } Refer to :ref:`How to add a new API `, implement this API. Then, start server, send a POST request(Content-Type=application/json) with a body like this: .. code-block:: json { "StringValue":"a string value", "int32Value":1234, "boolvalue":true } **NOTE**: Different from grpc, the key names are case-insensitive in case of thrift. You should be able to get the data in json in your thrift service func.