package jsonopts

import "github.com/go-json-experiment/json/internal/jsonopts"

Index

Variables

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.

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.

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.

var JoinUnknownOption = func(*Struct, Options) { 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)

Source Files

options.go

Version
v0.0.0-20250223041408-d3c622f1b874 (latest)
Published
Feb 23, 2025
Platform
linux/amd64
Imports
2 packages
Last checked
1 month ago

Tools for package owners.