Documentation ¶
Index ¶
- func Indent(dst *bytes.Buffer, src []byte, prefix, indent string) error
- func Marshal(v any) ([]byte, error)
- func MarshalIndent(v any, prefix, indent string) ([]byte, error)
- func Unmarshal(data []byte, v any) error
- func UnmarshalHandleDoubleEncode(bs []byte, v any) error
- func Valid(data []byte) bool
- type Decoder
- type Encoder
- type Interface
- type JSONiter
- type StdJSON
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalIndent ¶
MarshalIndent copied from encoding/json
func UnmarshalHandleDoubleEncode ¶
UnmarshalHandleDoubleEncode - due to a bug in xorm (see https://gitea.com/xorm/xorm/pulls/1957) - it's possible that a Blob may be double encoded or gain an unwanted prefix of 0xff 0xfe.
Types ¶
type Decoder ¶
Decoder represents a decoder for json
func NewDecoder ¶
NewDecoder creates a decoder to read objects from reader
type Encoder ¶
Encoder represents an encoder for json
func NewEncoder ¶
NewEncoder creates an encoder to write objects to writer
type Interface ¶
type Interface interface { Marshal(v any) ([]byte, error) Unmarshal(data []byte, v any) error NewEncoder(writer io.Writer) Encoder NewDecoder(reader io.Reader) Decoder Indent(dst *bytes.Buffer, src []byte, prefix, indent string) error }
Interface represents an interface to handle json data
var ( // DefaultJSONHandler default json handler DefaultJSONHandler Interface = JSONiter{jsoniter.ConfigCompatibleWithStandardLibrary} )
type JSONiter ¶
JSONiter implements Interface via jsoniter
func (JSONiter) Indent ¶
Indent implements Interface, since jsoniter don't support Indent, just use encoding/json's
func (JSONiter) NewDecoder ¶
NewDecoder implements Interface
func (JSONiter) NewEncoder ¶
NewEncoder implements Interface
type StdJSON ¶
type StdJSON struct{}
StdJSON implements Interface via encoding/json
func (StdJSON) NewDecoder ¶
NewDecoder implements Interface
func (StdJSON) NewEncoder ¶
NewEncoder implements Interface