Skip to content

Commit 0974616

Browse files
committed
types: chnage RawMessage to json.RawMessage
1 parent 11ee50b commit 0974616

File tree

2 files changed

+13
-27
lines changed

2 files changed

+13
-27
lines changed

types.go

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/francoispqt/gojay"
1414
)
1515

16+
// Version represents a JSONRPC version.
1617
const Version = "2.0"
1718

1819
// ID is a Request identifier.
@@ -70,20 +71,6 @@ func (m RawMessage) String() string {
7071
return *(*string)(unsafe.Pointer(&m))
7172
}
7273

73-
// Read implements io.Reader.
74-
// func (m *RawMessage) Read(p []byte) (n int, err error) {
75-
// if len(p) == 0 || p == nil {
76-
// return 0, nil
77-
// }
78-
// if m == nil {
79-
// return 0, io.EOF
80-
// }
81-
//
82-
// n = copy(p, *m)
83-
//
84-
// return n, nil
85-
// }
86-
8774
// MarshalJSON implements json.Marshaler.
8875
//
8976
// The returns m as the JSON encoding of m.
@@ -108,7 +95,6 @@ func (m *RawMessage) UnmarshalJSON(data []byte) error {
10895
return nil
10996
}
11097

111-
// var _ io.Reader = (*RawMessage)(nil)
11298
var _ json.Marshaler = (*RawMessage)(nil)
11399
var _ json.Unmarshaler = (*RawMessage)(nil)
114100

@@ -126,7 +112,7 @@ type Request struct {
126112
Method string `json:"method"`
127113

128114
// The method's params.
129-
Params *RawMessage `json:"params,omitempty"`
115+
Params *json.RawMessage `json:"params,omitempty"`
130116
}
131117

132118
// IsNotify returns true if this request is a notification.
@@ -151,7 +137,7 @@ type Response struct {
151137

152138
// The result of a request. This member is REQUIRED on success.
153139
// This member MUST NOT exist if there was an error invoking the method.
154-
Result *RawMessage `json:"result,omitempty"`
140+
Result *json.RawMessage `json:"result,omitempty"`
155141
}
156142

157143
// Combined represents a all the fields of both Request and Response.
@@ -166,14 +152,14 @@ type Combined struct {
166152
Method string `json:"method"`
167153

168154
// The method's params.
169-
Params *RawMessage `json:"params,omitempty"`
155+
Params *json.RawMessage `json:"params,omitempty"`
170156

171157
// The error object in case a request fails.
172158
Error *Error `json:"error,omitempty"`
173159

174160
// The result of a request. This member is REQUIRED on success.
175161
// This member MUST NOT exist if there was an error invoking the method.
176-
Result *RawMessage `json:"result,omitempty"`
162+
Result *json.RawMessage `json:"result,omitempty"`
177163
}
178164

179165
// NotificationMessage is a notification message.
@@ -187,5 +173,5 @@ type NotificationMessage struct {
187173
Method string `json:"method"`
188174

189175
// Params is the notification's params.
190-
Params *RawMessage `json:"params,omitempty"`
176+
Params *json.RawMessage `json:"params,omitempty"`
191177
}

types_gen.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
// Code generated by GoJay. DO NOT EDIT.
6-
75
package jsonrpc2
86

97
import (
8+
"encoding/json"
9+
1010
"github.com/francoispqt/gojay"
1111
)
1212

@@ -22,7 +22,7 @@ func (v *Request) UnmarshalJSONObject(dec *gojay.Decoder, k string) error {
2222
return dec.String(&v.Method)
2323
case "params":
2424
if v.Params == nil {
25-
v.Params = &RawMessage{}
25+
v.Params = &json.RawMessage{}
2626
}
2727
return dec.EmbeddedJSON((*gojay.EmbeddedJSON)(v.Params))
2828
}
@@ -58,7 +58,7 @@ func (v *Response) UnmarshalJSONObject(dec *gojay.Decoder, k string) error {
5858
return dec.Object(v.Error)
5959
case "result":
6060
if v.Result == nil {
61-
v.Result = &RawMessage{}
61+
v.Result = &json.RawMessage{}
6262
}
6363
return dec.EmbeddedJSON((*gojay.EmbeddedJSON)(v.Result))
6464
}
@@ -94,7 +94,7 @@ func (v *Combined) UnmarshalJSONObject(dec *gojay.Decoder, k string) error {
9494
return dec.String(&v.Method)
9595
case "params":
9696
if v.Params == nil {
97-
v.Params = &RawMessage{}
97+
v.Params = &json.RawMessage{}
9898
}
9999
return dec.EmbeddedJSON((*gojay.EmbeddedJSON)(v.Params))
100100
case "error":
@@ -104,7 +104,7 @@ func (v *Combined) UnmarshalJSONObject(dec *gojay.Decoder, k string) error {
104104
return dec.Object(v.Error)
105105
case "result":
106106
if v.Result == nil {
107-
v.Result = &RawMessage{}
107+
v.Result = &json.RawMessage{}
108108
}
109109
return dec.EmbeddedJSON((*gojay.EmbeddedJSON)(v.Result))
110110
}
@@ -136,7 +136,7 @@ func (v *NotificationMessage) UnmarshalJSONObject(dec *gojay.Decoder, k string)
136136
return dec.String(&v.Method)
137137
case "params":
138138
if v.Params == nil {
139-
v.Params = &RawMessage{}
139+
v.Params = &json.RawMessage{}
140140
}
141141
return dec.EmbeddedJSON((*gojay.EmbeddedJSON)(v.Params))
142142
}

0 commit comments

Comments
 (0)