Documentation
¶
Overview ¶
Package codec provides a model and conventions for marshaling and unmarshaling values to and from their encodings.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Codec ¶
type Codec struct {
Interface
}
Codec provides a wrapper around the basic interface to facilitate common codec operations
type IndentStyle ¶ added in v0.18.0
type IndentStyle int
IndentStyle identifies the whitespace character used for indentation.
const ( // IndentSpace indents using space characters. This is the default. IndentSpace IndentStyle = iota // IndentTab indents using tab characters. IndentTab )
The available indent styles
func (IndentStyle) MarshalText ¶ added in v0.18.0
func (s IndentStyle) MarshalText() ([]byte, error)
MarshalText provides the textual representation
func (IndentStyle) String ¶ added in v0.18.0
func (s IndentStyle) String() string
String returns the name of the indent style.
func (*IndentStyle) UnmarshalText ¶ added in v0.18.0
func (s *IndentStyle) UnmarshalText(b []byte) error
UnmarshalText converts the textual representation. In addition to the canonical values "space" and "tab", the common misspellings "spaces" and "tabs" are also accepted.
type Interface ¶ added in v0.11.0
type Interface interface {
MarshalWrite(w io.Writer, in any) error
UnmarshalRead(r io.Reader, out any) error
}
Interface defines the interface for reading and writing from data
type Option ¶ added in v0.14.1
type Option interface {
// contains filtered or unexported methods
}
Option implements options for codecs
func DisallowUnknownFields ¶ added in v0.14.1
func DisallowUnknownFields() Option
DisallowUnknownFields affects unmarshaling and prevents unknown fields from being specified.
func EscapeHTML ¶ added in v0.18.0
func EscapeHTML() Option
EscapeHTML affects marshaling and generates escaped HTML within JSON. For other codecs, this option generates an error.
func WithIndent ¶ added in v0.18.0
WithIndent affects marshaling and sets the string used for each level of indentation in the encoded output.
func WithIndentStyleSize ¶ added in v0.18.0
func WithIndentStyleSize(style IndentStyle, size int) Option
WithIndentStyleSize sets the indent based on style and style
type Options ¶ added in v0.15.0
type Options struct {
DisallowUnknownFields bool `mapstructure:"disallow_unknown_fields"`
IndentSize int `mapstructure:"indent_size"`
IndentStyle IndentStyle `mapstructure:"indent_style"`
EscapeHTML bool `mapstructure:"escape_html"`
}
Options represents all currently available codec options as data. It implements Option and can be decomposed into a list of individual options.