4
4
package jsonrpc2
5
5
6
6
import (
7
- stdjson "encoding/json"
8
7
"errors"
9
8
"fmt"
10
9
11
- json "github.com/goccy/go- json"
10
+ "github.com/segmentio/encoding/ json"
12
11
)
13
12
14
13
// Message is the interface to all JSON-RPC message types.
@@ -92,7 +91,7 @@ func (c Call) MarshalJSON() ([]byte, error) {
92
91
Params : & c .params ,
93
92
ID : & c .id ,
94
93
}
95
- data , err := stdjson .Marshal (req )
94
+ data , err := json .Marshal (req )
96
95
if err != nil {
97
96
return data , fmt .Errorf ("marshaling call: %w" , err )
98
97
}
@@ -103,7 +102,7 @@ func (c Call) MarshalJSON() ([]byte, error) {
103
102
// UnmarshalJSON implements json.Unmarshaler.
104
103
func (c * Call ) UnmarshalJSON (data []byte ) error {
105
104
var req wireRequest
106
- if err := json .UnmarshalNoEscape (data , & req ); err != nil {
105
+ if err := json .Unmarshal (data , & req ); err != nil {
107
106
return fmt .Errorf ("unmarshaling call: %w" , err )
108
107
}
109
108
@@ -171,7 +170,7 @@ func (r Response) MarshalJSON() ([]byte, error) {
171
170
resp .Result = & r .result
172
171
}
173
172
174
- data , err := stdjson .Marshal (resp )
173
+ data , err := json .Marshal (resp )
175
174
if err != nil {
176
175
return data , fmt .Errorf ("marshaling notification: %w" , err )
177
176
}
@@ -182,7 +181,7 @@ func (r Response) MarshalJSON() ([]byte, error) {
182
181
// UnmarshalJSON implements json.Unmarshaler.
183
182
func (r * Response ) UnmarshalJSON (data []byte ) error {
184
183
var resp wireResponse
185
- if err := json .UnmarshalNoEscape (data , & resp ); err != nil {
184
+ if err := json .Unmarshal (data , & resp ); err != nil {
186
185
return fmt .Errorf ("unmarshaling jsonrpc response: %w" , err )
187
186
}
188
187
@@ -266,7 +265,7 @@ func (n Notification) MarshalJSON() ([]byte, error) {
266
265
Method : n .method ,
267
266
Params : & n .params ,
268
267
}
269
- data , err := stdjson .Marshal (req )
268
+ data , err := json .Marshal (req )
270
269
if err != nil {
271
270
return data , fmt .Errorf ("marshaling notification: %w" , err )
272
271
}
@@ -277,7 +276,7 @@ func (n Notification) MarshalJSON() ([]byte, error) {
277
276
// UnmarshalJSON implements json.Unmarshaler.
278
277
func (n * Notification ) UnmarshalJSON (data []byte ) error {
279
278
var req wireRequest
280
- if err := json .UnmarshalNoEscape (data , & req ); err != nil {
279
+ if err := json .Unmarshal (data , & req ); err != nil {
281
280
return fmt .Errorf ("unmarshaling notification: %w" , err )
282
281
}
283
282
@@ -292,7 +291,7 @@ func (n *Notification) UnmarshalJSON(data []byte) error {
292
291
// DecodeMessage decodes data to Message.
293
292
func DecodeMessage (data []byte ) (Message , error ) {
294
293
var msg combined
295
- if err := json .UnmarshalNoEscape (data , & msg ); err != nil {
294
+ if err := json .Unmarshal (data , & msg ); err != nil {
296
295
return nil , fmt .Errorf ("unmarshaling jsonrpc message: %w" , err )
297
296
}
298
297
@@ -342,7 +341,7 @@ func DecodeMessage(data []byte) (Message, error) {
342
341
343
342
// marshalInterface marshal obj to json.RawMessage.
344
343
func marshalInterface (obj interface {}) (json.RawMessage , error ) {
345
- data , err := json .MarshalNoEscape (obj )
344
+ data , err := json .Marshal (obj )
346
345
if err != nil {
347
346
return json.RawMessage {}, fmt .Errorf ("failed to marshal json: %w" , err )
348
347
}
0 commit comments