Documentation ¶
Index ¶
- func Compact(dst *bytes.Buffer, src []byte) error
- func Dump(path string, v interface{}, prefix, indent string) error
- func HTMLEscape(dst *bytes.Buffer, src []byte)
- func Indent(dst *bytes.Buffer, src []byte, prefix, indent string) error
- func Load(path string, v interface{}) error
- func Marshal(v interface{}) ([]byte, error)
- func MarshalIndent(v interface{}, prefix, indent string) ([]byte, error)
- func MarshalNoHTMLEscape(v interface{}, prefix, indent string) ([]byte, error)
- func MarshalNoMapOrdering(v interface{}) ([]byte, error)
- func MarshalToString(v interface{}) (string, error)
- func Unmarshal(data []byte, v interface{}) error
- func UnmarshalFromString(data string, v interface{}) error
- func Valid(data []byte) bool
- type Decoder
- type Delim
- type Encoder
- type InvalidUTF8Error
- type InvalidUnmarshalError
- type Marshaler
- type MarshalerError
- type Number
- type RawMessage
- type SyntaxError
- type Token
- type UnmarshalFieldError
- type UnmarshalTypeError
- type Unmarshaler
- type UnsupportedTypeError
- type UnsupportedValueError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Dump ¶
Dump writes v to the named file at path using JSON encoding. It disables HTMLEscape. Optionally indent can be applied to the output, empty prefix and indent disables indentation. The output is friendly to read by humans.
func HTMLEscape ¶
func Load ¶
Load reads JSON-encoded data from the named file at path and stores the result in the value pointed to by v.
func Marshal ¶
Marshal returns the JSON encoding of v.
See encoding/json.Marshal for detailed document.
func MarshalIndent ¶
MarshalIndent is like Marshal but applies Indent to format the output.
See encoding/json.MarshalIndent for detailed document.
func MarshalNoHTMLEscape ¶
MarshalNoHTMLEscape is like Marshal but does not escape HTML characters. Optionally indent can be applied to the output, empty prefix and indent disables indentation. The output is more friendly to read for log messages.
func MarshalNoMapOrdering ¶
MarshalNoMapOrdering is like Marshal but does not sort map keys. It's useful to optimize performance where map key ordering is not needed.
It has effect only when build with tag "jsoniter", "gojson" or "unsafejson", else it is an alias name of Marshal.
func MarshalToString ¶
MarshalToString returns the JSON encoding of v as string.
See encoding/json.Marshal for detailed document.
func Unmarshal ¶
Unmarshal parses the JSON-encoded data and stores the result in the value pointed to by v.
See encoding/json.Unmarshal for detailed document.
func UnmarshalFromString ¶
UnmarshalFromString parses the JSON-encoded string data and stores the result in the value pointed to by v.
See encoding/json.Unmarshal for detailed document.
Types ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder is a wrapper of encoding/json.Decoder. It provides same methods as encoding/json.Decoder but with method chaining capabilities.
See encoding/json.Decoder for detailed document.
func NewDecoder ¶
NewDecoder returns a new Decoder that reads from r.
func (*Decoder) DisallowUnknownFields ¶
DisallowUnknownFields causes the Decoder to return an error when the destination is a struct and the input contains object keys which do not match any non-ignored, exported fields in the destination.
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Encoder is a wrapper of encoding/json.Encoder. It provides same methods as encoding/json.Encoder but with method chaining capabilities.
See encoding/json.Encoder for detailed document.
func NewEncoder ¶
NewEncoder returns a new Encoder that writes to w.
func (*Encoder) DisableMapOrdering ¶
DisableMapOrdering instructs the encoder to not sort map keys.
This option has effect only when build with tag "jsoniter", "gojson" or "unsafejson", else calling it is a no-op.
func (*Encoder) Encode ¶
Encode writes the JSON encoding of v to the stream, followed by a newline character.
See the documentation for Marshal for details about the conversion of Go values to JSON.
func (*Encoder) SetEscapeHTML ¶
SetEscapeHTML specifies whether problematic HTML characters should be escaped inside JSON quoted strings. The default behavior is to escape &, <, and > to \u0026, \u003c, and \u003e to avoid certain safety problems that can arise when embedding JSON in HTML.
In non-HTML settings where the escaping interferes with the readability of the output, SetEscapeHTML(false) disables this behavior.
type InvalidUTF8Error ¶
type InvalidUTF8Error = json.InvalidUTF8Error
type InvalidUnmarshalError ¶
type InvalidUnmarshalError = json.InvalidUnmarshalError
type Marshaler ¶
Marshaler is an alias name of encoding/json.Marshaler. See encoding/json.Marshaler for detailed document.
type MarshalerError ¶
type MarshalerError = json.MarshalerError
type RawMessage ¶
type RawMessage = json.RawMessage
type SyntaxError ¶
type SyntaxError = json.SyntaxError
type UnmarshalFieldError ¶
type UnmarshalFieldError = json.UnmarshalFieldError
type UnmarshalTypeError ¶
type UnmarshalTypeError = json.UnmarshalTypeError
type Unmarshaler ¶
type Unmarshaler = json.Unmarshaler
Unmarshaler is an alias name of encoding/json.Unmarshaler. See encoding/json.Unmarshaler for detailed document.
type UnsupportedTypeError ¶
type UnsupportedTypeError = json.UnsupportedTypeError
type UnsupportedValueError ¶
type UnsupportedValueError = json.UnsupportedValueError