File tree 1 file changed +7
-22
lines changed
1 file changed +7
-22
lines changed Original file line number Diff line number Diff line change @@ -119,30 +119,15 @@ func (r response) MarshalJSON() ([]byte, error) {
119
119
// > `error`:
120
120
// > This member is REQUIRED on error.
121
121
// > This member MUST NOT exist if there was no error triggered during invocation.
122
+ data := make (map [string ]interface {})
123
+ data ["jsonrpc" ] = r .Jsonrpc
124
+ data ["id" ] = r .ID
122
125
if r .Error != nil {
123
- // If there's an error, exclude result
124
- type responseWithoutResult struct {
125
- Jsonrpc string `json:"jsonrpc"`
126
- ID interface {} `json:"id"`
127
- Error * respError `json:"error"`
128
- }
129
- return json .Marshal (& responseWithoutResult {
130
- Jsonrpc : r .Jsonrpc ,
131
- ID : r .ID ,
132
- Error : r .Error ,
133
- })
134
- }
135
-
136
- type responseWithResult struct {
137
- Jsonrpc string `json:"jsonrpc"`
138
- Result interface {} `json:"result"`
139
- ID interface {} `json:"id"`
126
+ data ["error" ] = r .Error
127
+ } else {
128
+ data ["result" ] = r .Result
140
129
}
141
- return json .Marshal (& responseWithResult {
142
- Jsonrpc : r .Jsonrpc ,
143
- Result : r .Result ,
144
- ID : r .ID ,
145
- })
130
+ return json .Marshal (data )
146
131
}
147
132
148
133
type handler struct {
You can’t perform that action at this time.
0 commit comments