Documentation
¶
Overview ¶
Package json provides an interface to functions and types in the standard encoding/json package to facilitate mocking.
Index ¶
- func Marshal(v any) ([]byte, error)
- func MarshalIndent(v any, prefix, indent string) ([]byte, error)
- func Unmarshal(data []byte, v any) error
- type Decoder
- type DecoderOption
- type Delim
- type Encoder
- type EncoderOption
- type InvalidUnmarshalError
- type JSON
- type Marshaler
- type MarshalerError
- type Number
- type RawMessage
- type SyntaxError
- type Token
- type UnmarshalTypeError
- type Unmarshaler
- type UnsupportedTypeError
- type UnsupportedValueError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Marshal ¶ added in v0.2.15
Marshal returns the JSON encoding of v by calling encoding/json.Marshal.
func MarshalIndent ¶ added in v0.2.15
MarshalIndent returns formatted JSON encoding of v by calling encoding/json.MarshalIndent.
Types ¶
type Decoder ¶
type Decoder interface {
Decode(v any) error
Buffered() io.Reader
InputOffset() int64
More() bool
Token() (Token, error)
Nub() *json.Decoder
}
func NewDecoder ¶ added in v0.2.15
func NewDecoder(r io.Reader, options ...DecoderOption) Decoder
NewDecoder creates a new Decoder that reads from r with optional configuration.
func WrapDecoder ¶
type DecoderOption ¶
func WithDisallowUnknownFields ¶
func WithDisallowUnknownFields() DecoderOption
func WithUseNumber ¶
func WithUseNumber() DecoderOption
type Encoder ¶
type Encoder interface {
Encode(v any) error
SetIndent(prefix, indent string)
SetEscapeHTML(on bool)
Nub() *json.Encoder
}
func NewEncoder ¶ added in v0.2.15
func NewEncoder(w io.Writer, options ...EncoderOption) Encoder
NewEncoder creates a new Encoder that writes to w with optional configuration.
func WrapEncoder ¶
type EncoderOption ¶
func WithEscapeHTML ¶
func WithEscapeHTML(on bool) EncoderOption
func WithIndent ¶
func WithIndent(prefix, indent string) EncoderOption
type JSON ¶
type JSON interface {
// Functions:
Marshal(v any) ([]byte, error)
MarshalIndent(v any, prefix, indent string) ([]byte, error)
Unmarshal(data []byte, v any) error
Compact(dst *bytes.Buffer, src []byte) error
HTMLEscape(dst *bytes.Buffer, src []byte)
Indent(dst *bytes.Buffer, src []byte, prefix, indent string) error
Valid(data []byte) bool
// Constructors:
NewDecoder(r io.Reader, options ...DecoderOption) Decoder
NewEncoder(w io.Writer, options ...EncoderOption) Encoder
}
type MarshalerError ¶
type MarshalerError = json.MarshalerError
type RawMessage ¶
type RawMessage = json.RawMessage
type SyntaxError ¶
type SyntaxError = json.SyntaxError
type UnmarshalTypeError ¶
type UnmarshalTypeError = json.UnmarshalTypeError
type Unmarshaler ¶
type Unmarshaler = json.Unmarshaler
type UnsupportedTypeError ¶
type UnsupportedTypeError = json.UnsupportedTypeError
type UnsupportedValueError ¶
type UnsupportedValueError = json.UnsupportedValueError
Click to show internal directories.
Click to hide internal directories.