forked from mirror/go-json
Use type alias for Delim/Token/RawMessage type
This commit is contained in:
parent
dcd9023ac5
commit
9adc632469
|
@ -8,12 +8,6 @@ import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Delim rune
|
|
||||||
|
|
||||||
func (d Delim) String() string {
|
|
||||||
return string(d)
|
|
||||||
}
|
|
||||||
|
|
||||||
type decoder interface {
|
type decoder interface {
|
||||||
decode([]byte, int64, int64, unsafe.Pointer) (int64, error)
|
decode([]byte, int64, int64, unsafe.Pointer) (int64, error)
|
||||||
decodeStream(*stream, int64, unsafe.Pointer) error
|
decodeStream(*stream, int64, unsafe.Pointer) error
|
||||||
|
|
23
json.go
23
json.go
|
@ -3,7 +3,6 @@ package json
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
|
|
||||||
"github.com/goccy/go-json/internal/encoder"
|
"github.com/goccy/go-json/internal/encoder"
|
||||||
)
|
)
|
||||||
|
@ -280,7 +279,7 @@ func UnmarshalNoEscape(data []byte, v interface{}) error {
|
||||||
// string, for JSON string literals
|
// string, for JSON string literals
|
||||||
// nil, for JSON null
|
// nil, for JSON null
|
||||||
//
|
//
|
||||||
type Token interface{}
|
type Token = json.Token
|
||||||
|
|
||||||
// A Number represents a JSON number literal.
|
// A Number represents a JSON number literal.
|
||||||
type Number = json.Number
|
type Number = json.Number
|
||||||
|
@ -288,24 +287,10 @@ type Number = json.Number
|
||||||
// RawMessage is a raw encoded JSON value.
|
// RawMessage is a raw encoded JSON value.
|
||||||
// It implements Marshaler and Unmarshaler and can
|
// It implements Marshaler and Unmarshaler and can
|
||||||
// be used to delay JSON decoding or precompute a JSON encoding.
|
// be used to delay JSON decoding or precompute a JSON encoding.
|
||||||
type RawMessage []byte
|
type RawMessage = json.RawMessage
|
||||||
|
|
||||||
// MarshalJSON returns m as the JSON encoding of m.
|
// A Delim is a JSON array or object delimiter, one of [ ] { or }.
|
||||||
func (m RawMessage) MarshalJSON() ([]byte, error) {
|
type Delim = json.Delim
|
||||||
if m == nil {
|
|
||||||
return []byte("null"), nil
|
|
||||||
}
|
|
||||||
return m, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// UnmarshalJSON sets *m to a copy of data.
|
|
||||||
func (m *RawMessage) UnmarshalJSON(data []byte) error {
|
|
||||||
if m == nil {
|
|
||||||
return errors.New("json.RawMessage: UnmarshalJSON on nil pointer")
|
|
||||||
}
|
|
||||||
*m = data
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compact appends to dst the JSON-encoded src with
|
// Compact appends to dst the JSON-encoded src with
|
||||||
// insignificant space characters elided.
|
// insignificant space characters elided.
|
||||||
|
|
Loading…
Reference in New Issue