Thanks to visit codestin.com
Credit goes to pkg.go.dev

jsonopts

package standard library
go1.25.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 3, 2025 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultOptionsV1 = Struct{
	Flags: jsonflags.Flags{
		Presence: uint64(jsonflags.AllFlags & ^jsonflags.WhitespaceFlags),
		Values:   uint64(jsonflags.DefaultV1Flags),
	},
}

DefaultOptionsV1 is the set of all options that define default v1 behavior.

View Source
var DefaultOptionsV2 = Struct{
	Flags: jsonflags.Flags{
		Presence: uint64(jsonflags.AllFlags & ^jsonflags.WhitespaceFlags),
		Values:   uint64(0),
	},
}

DefaultOptionsV2 is the set of all options that define default v2 behavior.

View Source
var GetUnknownOption = func(Struct, Options) (any, bool) { panic("unknown option") }

GetUnknownOption is injected by the "json" package to handle Options declared in that package so that "jsonopts" can handle them.

View Source
var JoinUnknownOption = func(Struct, Options) Struct { panic("unknown option") }

JoinUnknownOption is injected by the "json" package to handle Options declared in that package so that "jsonopts" can handle them.

Functions

func GetOption

func GetOption[T any](opts Options, setter func(T) Options) (T, bool)

Types

type ArshalValues

type ArshalValues struct {
	Marshalers   any // jsonflags.Marshalers
	Unmarshalers any // jsonflags.Unmarshalers

	Format      string
	FormatDepth int
}

type ByteLimit

type ByteLimit int64 // jsontext.WithByteLimit

func (ByteLimit) JSONOptions

func (ByteLimit) JSONOptions(internal.NotForPublicUse)

type CoderValues

type CoderValues struct {
	Indent       string // jsonflags.Indent
	IndentPrefix string // jsonflags.IndentPrefix
	ByteLimit    int64  // jsonflags.ByteLimit
	DepthLimit   int    // jsonflags.DepthLimit
}

type DepthLimit

type DepthLimit int // jsontext.WithDepthLimit

func (DepthLimit) JSONOptions

func (DepthLimit) JSONOptions(internal.NotForPublicUse)

type Indent

type Indent string // jsontext.WithIndent

func (Indent) JSONOptions

func (Indent) JSONOptions(internal.NotForPublicUse)

type IndentPrefix

type IndentPrefix string // jsontext.WithIndentPrefix

func (IndentPrefix) JSONOptions

func (IndentPrefix) JSONOptions(internal.NotForPublicUse)

type Options

type Options interface {
	// JSONOptions is exported so related json packages can implement Options.
	JSONOptions(internal.NotForPublicUse)
}

Options is the common options type shared across json packages.

type Struct

type Struct struct {
	Flags jsonflags.Flags

	CoderValues
	ArshalValues
}

Struct is the combination of all options in struct form. This is efficient to pass down the call stack and to query.

func (*Struct) JSONOptions

func (*Struct) JSONOptions(internal.NotForPublicUse)

func (*Struct) Join

func (dst *Struct) Join(srcs ...Options)

func (*Struct) JoinWithoutCoderOptions

func (dst *Struct) JoinWithoutCoderOptions(srcs ...Options)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL