File tree 2 files changed +11
-22
lines changed
2 files changed +11
-22
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ package json
6
6
7
7
import (
8
8
"bytes"
9
- "errors "
9
+ "encoding/json "
10
10
"io"
11
11
)
12
12
@@ -259,27 +259,7 @@ func (enc *Encoder) SetEscapeHTML(on bool) {
259
259
// RawMessage is a raw encoded JSON value.
260
260
// It implements Marshaler and Unmarshaler and can
261
261
// be used to delay JSON decoding or precompute a JSON encoding.
262
- type RawMessage []byte
263
-
264
- // MarshalJSON returns m as the JSON encoding of m.
265
- func (m RawMessage ) MarshalJSON () ([]byte , error ) {
266
- if m == nil {
267
- return []byte ("null" ), nil
268
- }
269
- return m , nil
270
- }
271
-
272
- // UnmarshalJSON sets *m to a copy of data.
273
- func (m * RawMessage ) UnmarshalJSON (data []byte ) error {
274
- if m == nil {
275
- return errors .New ("json.RawMessage: UnmarshalJSON on nil pointer" )
276
- }
277
- * m = append ((* m )[0 :0 ], data ... )
278
- return nil
279
- }
280
-
281
- var _ Marshaler = (* RawMessage )(nil )
282
- var _ Unmarshaler = (* RawMessage )(nil )
262
+ type RawMessage = json.RawMessage
283
263
284
264
// A Token holds a value of one of these types:
285
265
//
Original file line number Diff line number Diff line change @@ -1236,3 +1236,12 @@ func TestMaintainOrderingIndented(t *testing.T) {
1236
1236
})
1237
1237
}
1238
1238
}
1239
+
1240
+ // This is a compile time check that encoding/json's RawMessage can be used in Operation
1241
+ func init () {
1242
+ msg := json .RawMessage ([]byte (`1` ))
1243
+
1244
+ _ = Operation {
1245
+ "foo" : & msg ,
1246
+ }
1247
+ }
You can’t perform that action at this time.
0 commit comments