Search and commands

↑ ↓ to select · Enter to open · Esc to close

Type to search packages.

marshaller

v2.2.0
go.gh.ink/json/v2/marshaller

Documentation

pkg.go.dev ↗

Table of contents

↓ to select · Enter to jump· Shift+Enter for source

7 matches

Top ↑

Functions

Marshal

func Marshal(v any, opts ...Options) ([]byte, error)

Marshal encodes v as JSON using the backend selected at build time.

Preheat

func Preheat(vt reflect.Type) error

Preheat compiles the codec for vt ahead of its first use. It is a no-op on backends that have nothing to compile.

PreheatMany

func PreheatMany(vts []reflect.Type) error

PreheatMany is the batch form of Preheat.

Unmarshal

func Unmarshal(data []byte, v any, opts ...Options) error

Unmarshal decodes JSON into v using the backend selected at build time.

Types

Options

type Options = jsonv2.Options

Options is encoding/json/v2's option type. It is an alias rather than a type of this package's own so that callers can pass any option constructor from encoding/json/v2, encoding/json/jsontext or encoding/json directly.

A future backend that is not encoding/json/v2 can still honour these: v2 exposes GetOption, which reads an option back out of a value and reports whether it was set at all, so this package can translate what the backend understands and fall back to encoding/json/v2 for the rest.

Dependency graph