Documentation
¶
Index ¶
- func AppendMarshal[T any](dst []byte, v T, opts ...MarshalOption) ([]byte, error)
- func DecodeValue[T any](d *Decoder, v *T) error
- func EncodeValue[T any](enc *Encoder, v T) error
- func Marshal[T any](v T, opts ...MarshalOption) ([]byte, error)
- func MarshalIndent[T any](v T, prefix, indent string, opts ...MarshalOption) ([]byte, error)
- func Unmarshal[T any](data []byte, v T, opts ...UnmarshalOption) error
- type Decoder
- type DecoderOption
- type Encoder
- type EncoderOption
- type InvalidUnmarshalError
- type MarshalOption
- func WithEscapeHTML() MarshalOption
- func WithEscapeLineTerms() MarshalOption
- func WithFastEscape() MarshalOption
- func WithFloatExpAuto() MarshalOption
- func WithStdCompat() MarshalOption
- func WithUTF8Correction() MarshalOption
- func WithoutEscapeHTML() MarshalOption
- func WithoutEscapeLineTerms() MarshalOption
- func WithoutUTF8Correction() MarshalOption
- type Marshaler
- type MarshalerError
- type Number
- type RawMessage
- type SyntaxError
- type UnmarshalOption
- type UnmarshalTypeError
- type Unmarshaler
- type UnsupportedTypeError
- type UnsupportedValueError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendMarshal ¶
func AppendMarshal[T any](dst []byte, v T, opts ...MarshalOption) ([]byte, error)
AppendMarshal appends the compact JSON encoding of v to dst.
func DecodeValue ¶
DecodeValue is a generic convenience wrapper around [Decoder.Decode].
func EncodeValue ¶
EncodeValue is a generic, zero-allocation alternative to [Encoder.Encode].
func Marshal ¶
func Marshal[T any](v T, opts ...MarshalOption) ([]byte, error)
Marshal returns the compact JSON encoding of v.
func MarshalIndent ¶
func MarshalIndent[T any](v T, prefix, indent string, opts ...MarshalOption) ([]byte, error)
MarshalIndent returns the indented JSON encoding of v.
Types ¶
type Decoder ¶
Decoder reads and decodes JSON values from an input stream.
func NewDecoder ¶
func NewDecoder(r io.Reader, opts ...DecoderOption) *Decoder
NewDecoder creates a Decoder that reads from r.
type DecoderOption ¶
type DecoderOption = vdec.DecoderOption
DecoderOption configures a Decoder.
func DecoderCopyString ¶
func DecoderCopyString() DecoderOption
DecoderCopyString causes all decoded strings to be heap-copied.
func WithBufferSize ¶
func WithBufferSize(size int) DecoderOption
WithBufferSize sets the initial read buffer size (default 128 KB).
func WithExpectedSize ¶ added in v0.1.3
func WithExpectedSize(size int) DecoderOption
WithExpectedSize hints the total input size (e.g. HTTP Content-Length).
func WithSkipErrors ¶
func WithSkipErrors(fn func(err error) bool) DecoderOption
WithSkipErrors enables skip-on-error recovery for NDJSON streams.
type Encoder ¶
Encoder writes JSON values to an output stream. Each Encode call writes one JSON value followed by a newline.
func NewEncoder ¶
func NewEncoder(w io.Writer, opts ...EncoderOption) *Encoder
NewEncoder creates an Encoder that writes to w.
type EncoderOption ¶
type EncoderOption = venc.EncoderOption
EncoderOption configures an Encoder.
func EncoderSetEscapeHTML ¶
func EncoderSetEscapeHTML(on bool) EncoderOption
EncoderSetEscapeHTML enables or disables escaping of <, >, and &.
func EncoderSetEscapeLineTerms ¶
func EncoderSetEscapeLineTerms(on bool) EncoderOption
EncoderSetEscapeLineTerms enables or disables escaping of U+2028 and U+2029.
func EncoderSetFloatExpAuto ¶
func EncoderSetFloatExpAuto(on bool) EncoderOption
EncoderSetFloatExpAuto enables encoding/json-compatible scientific notation for floats with |f| < 1e-6 or |f| >= 1e21.
func EncoderSetIndent ¶
func EncoderSetIndent(prefix, indent string) EncoderOption
EncoderSetIndent sets the indentation prefix and step for a new Encoder.
type InvalidUnmarshalError ¶
type InvalidUnmarshalError = jerr.InvalidUnmarshalError
type MarshalOption ¶
type MarshalOption = venc.MarshalOption
MarshalOption configures encoding behavior.
func WithEscapeHTML ¶
func WithEscapeHTML() MarshalOption
WithEscapeHTML enables escaping of <, >, & in strings.
func WithEscapeLineTerms ¶
func WithEscapeLineTerms() MarshalOption
WithEscapeLineTerms enables escaping of U+2028 and U+2029 line terminators in strings.
func WithFastEscape ¶
func WithFastEscape() MarshalOption
WithFastEscape disables all string-level escape features (UTF-8 validation, line terminator escaping, HTML escaping). Only mandatory JSON escapes (control chars, '"', '\\') are performed. This enables the fastest string encoding path in the native encoder.
func WithFloatExpAuto ¶
func WithFloatExpAuto() MarshalOption
WithFloatExpAuto enables encoding/json-compatible scientific notation for floats with |f| < 1e-6 or |f| >= 1e21 (e.g. 1e-7, 1e+21). By default, floats are always formatted in fixed-point notation.
func WithStdCompat ¶
func WithStdCompat() MarshalOption
WithStdCompat enables full encoding/json compatibility.
func WithUTF8Correction ¶
func WithUTF8Correction() MarshalOption
WithUTF8Correction enables replacing invalid UTF-8 with \ufffd in strings.
func WithoutEscapeHTML ¶
func WithoutEscapeHTML() MarshalOption
WithoutEscapeHTML disables escaping of <, >, &.
func WithoutEscapeLineTerms ¶
func WithoutEscapeLineTerms() MarshalOption
WithoutEscapeLineTerms disables escaping of U+2028 and U+2029.
func WithoutUTF8Correction ¶
func WithoutUTF8Correction() MarshalOption
WithoutUTF8Correction disables replacing invalid UTF-8 in strings.
type MarshalerError ¶
type MarshalerError = jerr.MarshalerError
type RawMessage ¶
type RawMessage = json.RawMessage
type SyntaxError ¶
type SyntaxError = jerr.SyntaxError
type UnmarshalOption ¶
type UnmarshalOption = vdec.UnmarshalOption
UnmarshalOption configures Unmarshal behavior.
func WithCopyString ¶
func WithCopyString() UnmarshalOption
WithCopyString causes all decoded strings to be heap-copied instead of zero-copy referencing the input buffer.
func WithUseNumber ¶
func WithUseNumber() UnmarshalOption
WithUseNumber causes numbers in interface{} fields to be decoded as json.Number instead of float64.
type UnmarshalTypeError ¶
type UnmarshalTypeError = jerr.UnmarshalTypeError
type Unmarshaler ¶
type Unmarshaler = json.Unmarshaler
type UnsupportedTypeError ¶
type UnsupportedTypeError = jerr.UnsupportedTypeError
type UnsupportedValueError ¶
type UnsupportedValueError = jerr.UnsupportedValueError
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
marshal
command
|
|
|
unmarshal
command
|
|
|
native
|
|
|
encvm
Package encvm provides the Go ↔ C bridge for the native JSON encoder VM.
|
Package encvm provides the Go ↔ C bridge for the native JSON encoder VM. |
|
gsdec
Package gsdec provides the Go ↔ C bridge for the goto-based native JSON decoder.
|
Package gsdec provides the Go ↔ C bridge for the goto-based native JSON decoder. |
|
rsdec
Package rsdec provides the Go ↔ Rust bridge for the native JSON decoder.
|
Package rsdec provides the Go ↔ Rust bridge for the native JSON decoder. |
|
Package ndec defines shared types for native JSON decoders (rsdec, gsdec).
|
Package ndec defines shared types for native JSON decoders (rsdec, gsdec). |
|
decoder
insn_exec materializes interface{} values from native-side instructions.
|
insn_exec materializes interface{} values from native-side instructions. |