Skip to content

Commit

Permalink
Remove JSON field tags from the jmessage type.
Browse files Browse the repository at this point in the history
Fix a case where the client wasn't marshaling correctly in the response to a
callback.
  • Loading branch information
creachadair committed Oct 26, 2021
1 parent 45f6c0e commit 120c060
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions json.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,16 @@ func (j *jmessages) parseJSON(data []byte) error {

// jmessage is the transmission format of a protocol message.
type jmessage struct {
V string `json:"jsonrpc"` // must be Version
ID json.RawMessage `json:"id,omitempty"` // may be nil
V string // must be Version
ID json.RawMessage // may be nil

// Fields belonging to request or notification objects
M string `json:"method,omitempty"`
P json.RawMessage `json:"params,omitempty"` // may be nil
M string
P json.RawMessage // may be nil

// Fields belonging to response or error objects
E *Error `json:"error,omitempty"` // set on error
R json.RawMessage `json:"result,omitempty"` // set on success
E *Error // set on error
R json.RawMessage // set on success

// N.B.: In a valid protocol message, M and P are mutually exclusive with E
// and R. Specifically, if M != "" then E and R must both be unset. This is
Expand Down
2 changes: 1 addition & 1 deletion opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ func (c *ClientOptions) handleCallback() func(*jmessage) []byte {
rsp.E = &Error{Code: code.FromError(err), Message: err.Error()}
}
}
bits, _ := json.Marshal(rsp)
bits, _ := rsp.toJSON()
return bits
}
}
Expand Down

0 comments on commit 120c060

Please sign in to comment.