Documentation ¶
Index ¶
- Variables
- func HTMLEscape(dst *bytes.Buffer, src []byte)
- func Marshal(v interface{}, encOptList ...*encOpts) ([]byte, error)
- func MarshalIndent(v interface{}, prefix, indent string) ([]byte, error)
- func MarshalString(v interface{}, encOptList ...*encOpts) (string, error)
- func MarshalStringIgnoreError(v interface{}, encOptList ...*encOpts) string
- func NewEncOpts(sliceMaxLength, mapMaxLength, stringMaxLength, maxReturnLength int) *encOpts
- type Marshaler
- type MarshalerError
- type Number
- type UnsupportedTypeError
- type UnsupportedValueError
Constants ¶
This section is empty.
Variables ¶
var DefaultEncOpts = NewEncOpts(5, 5, 2048, 4086)
修改默认的省略配置,请修改 DefaultEncOpts
Functions ¶
func HTMLEscape ¶
HTMLEscape appends to dst the JSON-encoded src with <, >, &, U+2028 and U+2029 characters inside string literals changed to \u003c, \u003e, \u0026, \u2028, \u2029 so that the JSON will be safe to embed inside HTML <script> tags. For historical reasons, web browsers don't honor standard HTML escaping within <script> tags, so an alternative JSON encoding must be used.
func MarshalIndent ¶
MarshalIndent is like Marshal but applies Indent to format the output. Each JSON element in the output will begin on a new line beginning with prefix followed by one or more copies of indent according to the indentation nesting.
func MarshalString ¶
func MarshalStringIgnoreError ¶
func MarshalStringIgnoreError(v interface{}, encOptList ...*encOpts) string
func NewEncOpts ¶
func NewEncOpts(sliceMaxLength, mapMaxLength, stringMaxLength, maxReturnLength int) *encOpts
Types ¶
type Marshaler ¶
Marshaler is the interface implemented by types that can marshal themselves into valid JSON.
type MarshalerError ¶
type MarshalerError struct { Type reflect.Type Err error // contains filtered or unexported fields }
A MarshalerError represents an error from calling a MarshalJSON or MarshalText method.
func (*MarshalerError) Error ¶
func (e *MarshalerError) Error() string
func (*MarshalerError) Unwrap ¶
func (e *MarshalerError) Unwrap() error
Unwrap returns the underlying error.
type UnsupportedTypeError ¶
An UnsupportedTypeError is returned by Marshal when attempting to encode an unsupported value type.
func (*UnsupportedTypeError) Error ¶
func (e *UnsupportedTypeError) Error() string
type UnsupportedValueError ¶
func (*UnsupportedValueError) Error ¶
func (e *UnsupportedValueError) Error() string