ktr0731 / evans

Evans: more expressive universal gRPC client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

failed to read input as JSON: bad input: expecting start of JSON object: '{' ; instead got [

XiaoLiu1020 opened this issue · comments

This is my question in following:

I use evans cli mode
evans --path $GOPATH/src --path . --proto pkg/api/gcserver.proto cli call api.GCServer.Cart --file cart_request.json

My gcserver.proto

message UpstreamRequest {
  string params = 1;
  string request_url = 2;
  map<string, UpstreamRequestHeaderValues> headers = 3;
}
message UpstreamRequestHeaderValues { repeated string values = 1; }

My cart_request.json

{
    "params": "yes",
    "request_url": "http://localhost:16048/cart/1",
    "headers":{
        "Request Method":["POST"]
    }
}

Why I run that command always have errors ?
evans: failed to run CLI mode: failed to call RPC 'Cart': failed to read input as JSON: bad input: expecting start of JSON object: '{' ; instead got [

I use vscode to edit in macOS Big Sur 11.6.4

commented

Please follow the issue template.


Your JSON input is not valid because it doesn't have values field. The following JSON input is valid.

{
  "params": "yes",
  "requestUrl": "http://localhost:16048/cart/1",
  "headers": {
    "Request Method": {
      "values": [
        "POST"
      ]
    }
  }
}