From c6c7b9aa99fb76ee5460ccd3912ba35d419d493d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Kupka?= Date: Wed, 2 Aug 2017 20:50:46 +0200 Subject: [PATCH] Response: Add omitempty tag for Result (#14) The 'result' key MUST be unset according when the error key is set. This is not what is happening right now. When the error is set, "result":null is returned in the response payload. This patch is fixing the issue by adding omitempty for the result field. --- jsonrpc2.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jsonrpc2.go b/jsonrpc2.go index fb95f7a..54f6833 100644 --- a/jsonrpc2.go +++ b/jsonrpc2.go @@ -128,7 +128,7 @@ func (r *Request) SetMeta(v interface{}) error { // http://www.jsonrpc.org/specification#response_object. type Response struct { ID ID `json:"id"` - Result *json.RawMessage `json:"result"` + Result *json.RawMessage `json:"result,omitempty"` Error *Error `json:"error,omitempty"` // Meta optionally provides metadata to include in the response.