douang4294 2015-11-05 10:16
浏览 145

Jsonrpc4j和go的rpc / jsonrpc之间的JSONRPC格式不同

I was meet a problem when I tried used net/jsonrpc package to build a server and a Java client with jsonrpc4j

The problem is jsonrpc4j is when error happen, golang`s method will return error and encoding to json.

I got this json object in client

{"id": -6028374044949000, "result": null, "error": "some error return message"}

This object cast failed in java's json4j.

http://www.jsonrpc.org/specification#error_object

After I checked the jsonrpc page, it is said the error field MUST a json object with fields [code, message, date], the golang jsonrpc package not meet the require.

So I`m confused how to solve this. Change the jsonrpc lib, Just replace the rpc way to thrift/gRpc, Avoid to return error but send error in reply and let Java check the response, Or just edited the json4j or golang's source code ( I'm very horrible about this option)

Thanks for watch.

  • 写回答

1条回答 默认 最新

  • douxi4414 2015-11-05 17:37
    关注

    If you need JSON-RPC 2.0 support for Go you can try https://github.com/powerman/rpc-codec

    评论

报告相同问题?

悬赏问题

  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集