Merge pull request #160 from goccy/feature/use-type-alias

Use type alias for Delim/Token/RawMessage type
This commit is contained in:
Masaaki Goshima 2021-03-20 21:33:07 +09:00 committed by GitHub
commit 336d414892
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 25 deletions

View File

@ -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

23
json.go
View File

@ -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.