Documentation ¶
Index ¶
- func Indent(dst *bytes.Buffer, src []byte, prefix, indent string) error
- func Marshal(v interface{}) ([]byte, error)
- func MarshalIndent(v interface{}, prefix, indent string) ([]byte, error)
- func Unmarshal(data []byte, v interface{}) error
- func UnmarshalHandleDoubleEncode(bs []byte, v interface{}) error
- func Valid(data []byte) bool
- type Decoder
- type Encoder
- type Interface
- type JSONiter
- func (j JSONiter) Indent(dst *bytes.Buffer, src []byte, prefix, indent string) error
- func (j JSONiter) Marshal(v interface{}) ([]byte, error)
- func (j JSONiter) NewDecoder(reader io.Reader) Decoder
- func (j JSONiter) NewEncoder(writer io.Writer) Encoder
- func (j JSONiter) Unmarshal(data []byte, v interface{}) error
- 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 ¶
type Decoder interface {
Decode(v interface{}) error
}
Decoder represents a decoder for json
func NewDecoder ¶
NewDecoder creates a decoder to read objects from reader
type Encoder ¶
type Encoder interface {
Encode(v interface{}) error
}
Encoder represents an encoder for json
func NewEncoder ¶
NewEncoder creates an encoder to write objects to writer
type Interface ¶
type Interface interface { Marshal(v interface{}) ([]byte, error) Unmarshal(data []byte, v interface{}) 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