From 9adc632469ad066f773c0c661c8eebb2a8a5f07a Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Sat, 20 Mar 2021 20:41:01 +0900 Subject: [PATCH] Use type alias for Delim/Token/RawMessage type --- decode.go | 6 ------ json.go | 23 ++++------------------- 2 files changed, 4 insertions(+), 25 deletions(-) diff --git a/decode.go b/decode.go index e5c4064..d06136d 100644 --- a/decode.go +++ b/decode.go @@ -8,12 +8,6 @@ import ( "unsafe" ) -type Delim rune - -func (d Delim) String() string { - return string(d) -} - type decoder interface { decode([]byte, int64, int64, unsafe.Pointer) (int64, error) decodeStream(*stream, int64, unsafe.Pointer) error diff --git a/json.go b/json.go index 3ebba68..3d879d0 100644 --- a/json.go +++ b/json.go @@ -3,7 +3,6 @@ package json import ( "bytes" "encoding/json" - "errors" "github.com/goccy/go-json/internal/encoder" ) @@ -280,7 +279,7 @@ func UnmarshalNoEscape(data []byte, v interface{}) error { // string, for JSON string literals // nil, for JSON null // -type Token interface{} +type Token = json.Token // A Number represents a JSON number literal. type Number = json.Number @@ -288,24 +287,10 @@ type Number = json.Number // RawMessage is a raw encoded JSON value. // It implements Marshaler and Unmarshaler and can // 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. -func (m RawMessage) MarshalJSON() ([]byte, error) { - 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 -} +// A Delim is a JSON array or object delimiter, one of [ ] { or }. +type Delim = json.Delim // Compact appends to dst the JSON-encoded src with // insignificant space characters elided.