package decoder

Import Path
	github.com/goccy/go-json/internal/decoder (on go.dev)

Dependency Relation
	imports 31 packages, and imported by one package


Package-Level Type Names (total 21)
/* sort by: | */
type BasePathNode (struct)
( Decoder) Decode(*RuntimeContext, int64, int64, unsafe.Pointer) (int64, error) ( Decoder) DecodePath(*RuntimeContext, int64, int64) ([][]byte, int64, error) func CompileToGetDecoder(typ unsafe.Pointer) (Decoder, error) func CompileToGetDecoderV2(typ unsafe.Pointer, flags V2Flags) (Decoder, error) func NewPathDecoder() Decoder func (*RuntimeContext).DecoderOf(typ unsafe.Pointer) (Decoder, error) func (*RuntimeContext).DecoderOfV2(typ unsafe.Pointer) (Decoder, error) func (*Stream).DecoderOf(typ unsafe.Pointer) (Decoder, error) func DecodeWholeInV2(ctx *RuntimeContext, buf []byte, cursor, end, depth int64, dec Decoder, p unsafe.Pointer) (int64, error) func ReadsJSONText(dec Decoder) bool func (*Stream).Decode(dec Decoder, typ unsafe.Pointer, p unsafe.Pointer) error func (*Stream).DecodeLongV2After(dec Decoder, p unsafe.Pointer, depth, from, start int64) error func (*Stream).DecodeV2(dec Decoder, p unsafe.Pointer, depth int64) error func (*Stream).DecodeV2After(dec Decoder, p unsafe.Pointer, depth, from, start int64) error
Context context.Context Flags OptionFlags Path *Path V2 is in the room which Flags leaves before Context on 64-bit platforms, so that Option keeps its size there.
const ContextOption const DisallowUnknownFieldsOption const FirstWinOption const NoCopyStringOption const PathOption const UseNumberOption
DoubleQuotePathSelector bool RootSelectorOnly bool SingleQuotePathSelector bool (*Path) Field(sel string) (PathNode, bool, error) (*Path) Get(src, dst reflect.Value) error (*Path) String() string *Path : github.com/pancsta/asyncmachine-go/internal/nofmt.Stringer *Path : github.com/pandatix/go-abnf.ElemItf *Path : expvar.Var *Path : fmt.Stringer func (*PathBuilder).Build(buf []rune) (*Path, error) func PathString.Build() (*Path, error) func (*RuntimeContext).SetPath(p *Path)
(*PathBuilder) Build(buf []rune) (*Path, error)
BasePathNode *BasePathNode (*PathIndexAllNode) Field(fieldName string) (PathNode, bool, error) (*PathIndexAllNode) Get(src, dst reflect.Value) error (*PathIndexAllNode) Index(idx int) (PathNode, bool, error) (*PathIndexAllNode) String() string *PathIndexAllNode : PathNode *PathIndexAllNode : github.com/pancsta/asyncmachine-go/internal/nofmt.Stringer *PathIndexAllNode : github.com/pandatix/go-abnf.ElemItf *PathIndexAllNode : expvar.Var *PathIndexAllNode : fmt.Stringer
BasePathNode *BasePathNode (*PathIndexNode) Field(fieldName string) (PathNode, bool, error) (*PathIndexNode) Get(src, dst reflect.Value) error (*PathIndexNode) Index(idx int) (PathNode, bool, error) (*PathIndexNode) String() string *PathIndexNode : PathNode *PathIndexNode : github.com/pancsta/asyncmachine-go/internal/nofmt.Stringer *PathIndexNode : github.com/pandatix/go-abnf.ElemItf *PathIndexNode : expvar.Var *PathIndexNode : fmt.Stringer
( PathNode) Field(fieldName string) (PathNode, bool, error) ( PathNode) Get(src, dst reflect.Value) error ( PathNode) Index(idx int) (PathNode, bool, error) ( PathNode) String() string *PathIndexAllNode *PathIndexNode *PathRecursiveNode *PathSelectorNode PathNode : github.com/pancsta/asyncmachine-go/internal/nofmt.Stringer PathNode : github.com/pandatix/go-abnf.ElemItf PathNode : expvar.Var PathNode : fmt.Stringer func (*Path).Field(sel string) (PathNode, bool, error) func (*PathIndexAllNode).Field(fieldName string) (PathNode, bool, error) func (*PathIndexAllNode).Index(idx int) (PathNode, bool, error) func (*PathIndexNode).Field(fieldName string) (PathNode, bool, error) func (*PathIndexNode).Index(idx int) (PathNode, bool, error) func PathNode.Field(fieldName string) (PathNode, bool, error) func PathNode.Index(idx int) (PathNode, bool, error) func (*PathRecursiveNode).Field(fieldName string) (PathNode, bool, error) func (*PathRecursiveNode).Index(_ int) (PathNode, bool, error) func (*PathSelectorNode).Field(fieldName string) (PathNode, bool, error) func (*PathSelectorNode).Index(idx int) (PathNode, bool, error)
BasePathNode *BasePathNode (*PathRecursiveNode) Field(fieldName string) (PathNode, bool, error) Get assigns to dst a slice of the values which the name of n has at any depth of src, in the members of objects and the elements of arrays, with the rest of the path applied to each of them: a value in which the rest finds nothing adds nothing. (*PathRecursiveNode) Index(_ int) (PathNode, bool, error) (*PathRecursiveNode) String() string *PathRecursiveNode : PathNode *PathRecursiveNode : github.com/pancsta/asyncmachine-go/internal/nofmt.Stringer *PathRecursiveNode : github.com/pandatix/go-abnf.ElemItf *PathRecursiveNode : expvar.Var *PathRecursiveNode : fmt.Stringer
BasePathNode *BasePathNode (*PathSelectorNode) Field(fieldName string) (PathNode, bool, error) (*PathSelectorNode) Get(src, dst reflect.Value) error (*PathSelectorNode) Index(idx int) (PathNode, bool, error) (*PathSelectorNode) String() string *PathSelectorNode : PathNode *PathSelectorNode : github.com/pancsta/asyncmachine-go/internal/nofmt.Stringer *PathSelectorNode : github.com/pandatix/go-abnf.ElemItf *PathSelectorNode : expvar.Var *PathSelectorNode : fmt.Stringer
( PathString) Build() (*Path, error)
const DoubleQuotePathSelector const SingleQuotePathSelector
Buf []byte Option *Option CurrentV2Call returns the state of the call of the v2 json package which decodes by ctx, which the call made by V2Call, so it is never nil. DecoderOf returns the decoder of the type, compiling it if the type is new. A runtime context remembers the decoders of the types it decoded last: the same types are decoded again and again in most of the programs, and this is cheaper than a lookup of the table shared by every goroutine. The first entry of the set is looked at here; the rest in lookupDecoder. DecoderOfV2 returns the decoder of the semantics of encoding/json/v2 of the type, for the options and the functions of unmarshaling of ctx. The decoder of a call without functions is remembered with the decoders of the context as v1's DecoderOf remembers them, under the address of the type with the marks of the decoders of v2. A decoder in neither entry of its set is the one of the shared table, which takes the first entry, and the one decoded before it the second. DiscardTypeError drops the type error of a decoding which failed with another error. HasTypeError reports whether the decoding has a type error, which TypeError returns: the type of the value is made for it only. InputSyntaxError returns the first syntax error of the input of the decoding, as encoding/json reports it, or nil if the input is valid: the decoders report a syntax error as they meet it, which this reports again as encoding/json does, which checks the whole input first. The input is copied again, since the decoding writes its buffer, as the escapes of the keys are decoded in it. ReadValue reads the value at cursor whole, as the method of unmarshaling, or the function, of a value of typ is given it: it must have the text which v2 allows ( see skipValueV2 ). It returns the start and the end of the value. An error of the text is one of the value, at its start, which the v2 json package reads whole to find it again, as encoding/json/v2 reads it. RecordV1Error records err, an error of the decoding of a value with ReportErrorsWithLegacySemantics, as the type error of encoding/json, if it is the first one, and reports whether the decoding goes on after it: the error of a value which encoding/json/v2 reports as its SemanticError doesn't stop it, but a syntax error, an error of the reader, a name which another member has, and a syntax error or an error of the reader which a method or a function returned, do, as encoding/json stops at them. SetInput copies data to the buffer of the context, followed by a nul byte which ends every scan, and makes it the buffer to decode. SetPath makes the decoding select the values of p. It selects by a copy of p, as it moves the node of the path it is at: p stays as it is for the next call, after one which fails too, and for the calls which other goroutines make at the same time. TakeValue returns the address of a zero value of typ in the heap, which the context keeps for the next call with the same type. typ is given as its type descriptor too, which is how it is looked up. TypeError returns the first type error of the decoding of the value at base into a value of typ, or nil if the decoding had none. Its offset is relative to offsetBase. outer are the steps of the path to the value in the values which it is in, which a decoder of jsontext read it in, unescaped, or nil. V2Call returns the state of the call of the v2 json package which decodes by ctx, which it makes the first time. V2TypeError returns the type error which a decoder of v1 recorded, as the error of v2 ( see v2Error ), or nil if none did. func TakeRuntimeContext() *RuntimeContext func (*Stream).Context() *RuntimeContext func DecodeWholeInV2(ctx *RuntimeContext, buf []byte, cursor, end, depth int64, dec Decoder, p unsafe.Pointer) (int64, error) func ReleaseRuntimeContext(ctx *RuntimeContext) func SetBuf(ctx *RuntimeContext, buf []byte) func SetV2Flags(ctx *RuntimeContext, flags V2Flags) func Decoder.Decode(*RuntimeContext, int64, int64, unsafe.Pointer) (int64, error) func Decoder.DecodePath(*RuntimeContext, int64, int64) ([][]byte, int64, error)
Stream reads the values of a JSON text from an io.Reader one by one. A value is decoded by the same decoders as a byte slice is: a value which the buffer holds whole is decoded from it, with a nul byte put after the value, and an object or an array which it doesn't is decoded element by element as it is read ( see scanFailed ), so that the buffer keeps its size. The decoded strings are copied out of the buffer, so that a value keeps alive no memory but its own, and the buffer is reused in place when it is full: the bytes which are not consumed yet are moved to its start. Under NoCopyStringOption, the strings refer to the buffer, which is then never written again: the bytes are copied to a new one instead ( see referred ). Option *Option AfterTopLevel moves the stream to the end of the input after its top-level value, which only white space may follow, and reports whether it is there: if not, the place of the byte after the value is recorded ( see V2Call.Place ). It returns the error of the reader. BeginV2 makes the stream, which has no reader ( see EndV2 ), read r, for a decoding of v2 by the state of the call of its context, whose path is the top level. BeginV2At is BeginV2 for a value at the place levels, whose names are its own, which are made the path of the call of the stream, without a copy ( see SetPath ). It returns the path the call had, whose arrays the caller keeps for its next levels. BorrowV2 makes the stream, which BeginV2 or BeginV2At began, read the input of dec, a jsontext.Decoder, from the offset from of the whole input, in the buffer of dec, in place, and read more into it through dec, initBufSize bytes at most at a time, as it reads its reader ( see readSource ): the bytes are not copied into its own buffer. It reports false, having done nothing, if the buffer can't be read so ( see textcoder.DecoderBuffer ). Once a decoder attached at a value reads on, the stream holds what it needs of the buffer in its own, and reads its reader ( see ReadOn ). Buffered returns a reader of the data read from the reader but not consumed yet. Context returns the context of the stream, which its values are decoded by. Decode decodes the next value of the stream into p, of the pointer type typ, by dec. If the value has a type error, the stream goes on after the value, as the one of encoding/json does. DecodeLongV2After is DecodeV2After for an object or an array at the offset start of what has been read, which the caller found not whole in it ( see WholeEndV2 ), by dec, which is not the decoder of a method, a function or a pointer ( see ReadsJSONText ): it is decoded element by element at once, as decodeTopV2 decodes it after its scan. DecodeV2 decodes the next value of the stream by dec, a decoder of v2, into p: whole if the buffer holds it, and else element by element. The value is nested in depth objects and arrays, the ones of the path but the top level. It returns the error of the reader, io.EOF at the end of the input, if no value is left, and the error of the decoding, whose place is recorded ( see V2Call.Place ) unless it is an error of encoding/json/v2 at its place. DecodeV2After is DecodeV2 for a value at the offset start of the input, after from, the offset of the end of the token before it, which the stream reads from: the white space and the delimiter between them, which were checked, are skipped. It never returns io.EOF. DecoderOf returns the decoder of the type, from the recent decoders of the context of the stream. Drop empties the buffer of the stream, which a decoder attached at its value read on from and failed after: the stream has nothing to give back ( see Read ), as the decoding of the value fails. EndV2 drops the reader of the stream and the state of its call, which may then read another reader ( see BeginV2 ). InputOffset returns the offset of the stream which Decoder.InputOffset reports: the end of the last token or value read, or where a read which failed started. LendAt makes the stream, which BorrowV2 made read the buffer of a jsontext.Decoder from the offset from, the end of the token before its next value, at that value, at the offset start, as decodeWholeV2 is while it decodes it: for a value which the caller decodes whole in the buffer ( see V2Hooks.Lend ). More reports whether the current array or object has another element: at the end of the input in one, it reports true, and the error of the end is returned by the next read, as encoding/json of Go 1.27 does. Offset returns the offset in the input of the cursor of the stream. PlaceWholeV2 records the place of err, the error of the value at the cursor, which the caller decoded whole in the buffer up to end ( see DecodeWholeInV2 ), after from, the total offset of the end of the token before it, as decodeWholeV2 records it. It returns err. Read returns what has been read and not dropped, and the offset of its first byte in the input. ReadAllV2 returns the whole input of the stream, which has read nothing yet, up to the end of its reader, followed by a nul byte and the padding which the decoders may read after it ( see SetInput ), or the error of the reader if it fails. ReadError returns the error of the reader, which the stream reports at the end of what it read, or nil if the reader reached the end of the input, or has not failed. ReadOn reads more of the input into p, for a decoder attached at the value of the stream ( see V2Call.Value ): initBufSize bytes at most, as the stream reads, and the error of the reader is kept, as the stream keeps it. ReadsInPlace reports whether the stream reads the buffer of a jsontext.Decoder in place ( see BorrowV2 ), which what it has read is then: it has not left it for its own buffer ( see leaveSource ). RestorePath sets the path of the call of the stream back to saved, which SetPath returned, and returns the path which it set, whose arrays the caller keeps for the next SetPath. Resume makes the stream go on at the offset end of the input, where a decoder attached at its value stopped: in the buffer, or, if the decoder read on, before rest, what it read and didn't use, which the buffer takes. SetPath sets the path of the call of the stream to levels, the place of the next value which it decodes, copied into path, whose arrays it reuses, and returns the path it had, which the caller sets back by RestorePath. StartAt makes the stream, which has read nothing, start at the offset of the input, which its reader reads from. Token returns the next token of the stream: a delimiter, a string, a number, a bool or nil. The commas and the colons are consumed where the grammar has them. TotalOffset returns the number of the bytes consumed from the reader. Unread returns the bytes of the buffer which the stream read after its cursor. ViewV2 makes the stream, which BeginV2At began, read in place in, a whole input, which has a nul byte after it, from the offset base of the whole input: it reads nothing more, and its buffer is its own again after EndV2. A caller which decodes a value of in whole, as decodeWholeV2 decodes the value of a stream, sets the stream at the value ( see LendAt ), so that a method or a function of the value finds its place by the stream. func NewStream(r io.Reader) *Stream func NewStreamV2() *Stream func TakeStreamV2(r io.Reader) *Stream func ReleaseStreamV2(s *Stream)
StreamPlace is the part of the buffer of a stream where an error of its decoding of v2 is found again: from From, the end of the token before the member, the element or the value which failed, in the innermost level of the path, up to End ( see V2Call.Path ). End int64 From int64 Set bool
StreamValue is the value of a stream which a decoder of v2 decodes, in the innermost level of the path, for a method or a function which reads a jsontext.Decoder, which is attached at its place: From and Start are the offsets in the buffer of the end of the token before the value and of the value. ReadsOn is set for a value which the buffer doesn't hold whole, which the decoder reads on from the reader of the stream ( see Stream.ReadOn ). From int64 ReadsOn bool Start int64
UnmarshalFunc is a function of unmarshaling, for the values of the types castable to Type ( see runtime.CastableTo ). Decode decodes the value at cursor into the value at p, of the type from, and returns the cursor after it, or ErrUseDefault if the function declined the value, which a function of UnmarshalFromFunc may. FromDecoder is set for a function of UnmarshalFromFunc, which reads a jsontext.Decoder: a stream gives it a value which it hasn't read whole ( see V2Call.Attach ), and any other function the value read whole. Type reflect.Type
UnmarshalFuncs are the functions of unmarshaling of a call, in the order they are tried, with the decoders compiled for them. Funcs []UnmarshalFunc
V2Call is the state of a call of the v2 json package which its decoders read, which a context keeps from a call to the next once a call made it ( see RuntimeContext.V2Call ). Config are the options of the call, which a method or a function of unmarshaling which reads a jsontext.Decoder is given. From is the state of the v2 json package for the methods and the functions which read a jsontext.Decoder, which the decoder doesn't know. Funcs are the functions of unmarshaling of the call, which the decoders are compiled for ( see DecoderOfV2 ), or nil. Lent is the call of UnmarshalDecode which decodes the value of the call in the buffer of its decoder, without the stream, which it sets up for a method or a function which reads a jsontext.Decoder ( see V2Hooks.Lend ), or nil. Options are the options of a call of Unmarshal or of UnmarshalRead which has options, which Config points to: the context, which a pool keeps, holds them for its calls. Path []textcoder.Level Place is where the error which the decoding of the stream returned is found again ( see StreamPlace ). Stream is the stream which the call decodes, or nil for an input of its own, with the state of its decoding element by element ( see Stream.DecodeV2 ): Path is the place of the value which is decoded, a level for each object and array which it is in, the top level first ( see textcoder.Level ), and Value the value of the innermost level which a decoder of v2 decodes. Value StreamValue func (*RuntimeContext).CurrentV2Call() *V2Call func (*RuntimeContext).V2Call() *V2Call
V2Flags are the options of a decoding by the semantics of encoding/json/v2, which the v2 json package decodes by ( see CompileToGetDecoderV2 ). They are zero for the decodings of v1. func CompileToGetDecoderV2(typ unsafe.Pointer, flags V2Flags) (Decoder, error) func IsV2Bytes(typ reflect.Type, flags V2Flags) bool func SetV2Flags(ctx *RuntimeContext, flags V2Flags) const V2AllowDuplicateNames const V2AllowInvalidUTF8 const V2CallMethodsWithLegacySemantics const V2FormatByteArrayAsArray const V2FormatBytesWithLegacySemantics const V2FormatDurationAsNano const V2MatchCaseInsensitiveNames const V2MatchCaseSensitiveDelimiter const V2MergeWithLegacySemantics const V2ParseBytesWithLooseRFC4648 const V2ParseTimeWithLooseRFC3339 const V2RejectUnknownMembers const V2ReportErrorsWithLegacySemantics const V2Semantics const V2StringifyNumbers const V2StringifyWithLegacySemantics const V2UnmarshalArrayFromAnyLength
Package-Level Functions (total 20)
AssignValue sets src, cast to the type which dst points to, to the value dst points to. dst must be a pointer which is not nil. The value is not changed when src cannot be cast.
CompileToGetDecoder returns the decoder of the type. The type is given by the pointer to its type descriptor, which the caller reads from an interface value, because reflect.Type is required only when the decoder is not cached yet.
CompileToGetDecoderV2 returns the decoder of the type for the semantics of encoding/json/v2 and the options flags, of which StringifyNumbers and the ones of v1DecoderOptions change the decoders, compiling it if the type is new.
DecodeWholeInV2 decodes the value of buf from cursor up to end, which buf holds whole, by dec into p, as decodeWholeV2 decodes the value of a stream which the buffer holds whole: nested in depth objects and arrays, in buf, whose byte at end is nul while the value is decoded. A type error which a decoder of v1 recorded is the error of the value, and the names of the objects of the value which an error ended are dropped after it, as DecodeV2After drops them.
IsArrayLengthError reports whether err is the error of the length of a JSON array decoded into a Go array, which is at the end of the JSON array.
IsV2Bytes reports whether typ, a slice or an array, is of bytes for the options flags, whose value is a base64 string: a []byte or a [N]byte, but a [N]byte with FormatByteArrayAsArray, and a slice or an array of a named byte type with FormatBytesWithLegacySemantics, which is otherwise a JSON array of its values.
NewInput returns the buffer which the decoders decode: a copy of the input followed by a nul byte, which ends every scan.
NewStreamV2 returns a new stream for the decodings of v2, which a pool keeps: its context has the decoders of the types decoded last, as a context of the pool of the contexts has them ( see RuntimeContext.recentDecoders ).
ReadsJSONText reports whether dec is the decoder of a method or a function which reads a jsontext.Decoder, which may read on past its value, or of a pointer, whose value may be one: decodeTopV2 decodes them by decodeNestedV2.
ReleaseStreamV2 puts the stream back, without its reader and the state of its call ( see EndV2 ).
SetBuf makes buf, an input followed by a nul byte which the caller keeps, the input of the decoding of ctx, whose strings are copied out of it, as they are out of an input of SetInput. A nil buf drops it. It is a function, not a method: a method of the context moves the data of the binary ( its method table ), which slows its decoding.
SetV2Flags sets the options of v2 of ctx for a decoding, which every setting of them before a decoding is made by, as the others clear them after one: the recent decoders are emptied if they were compiled for other options of encoding/json which change the decoders, which their keys have no room for ( see recentV1Options ), once for the call rather than in every DecoderOfV2, by a call of its own, so that SetV2Flags is inlined into the callers.
TakeStreamV2 returns a stream which reads r, for a decoding of v2 by the state of the call of its context ( see RuntimeContext.V2Call ), whose path is the top level.
Valid reports whether buf, the input followed by the nul byte, is a JSON value, by the grammar which the values which are not decoded are skipped by.
ValidateEnd returns the syntax error of what follows the value which ends at cursor in buf, the input followed by the nul byte: white spaces only may follow it, up to the end of the input. A nul byte in the input is a byte which the grammar doesn't have there, as encoding/json has it.
WholeEndV2 returns the end of the object or the array at cursor of buf, which has the input up to length, followed by the room of a decoder ( see textcoder.InputRoom ), and reports whether it ends there: false for any other value.
Package-Level Variables (total 3)
ErrUseDefault is the error of a method or a function of unmarshaling which declined a value without reading it: the next function, or the next method or the kind of the type, decodes it.
V2Hooks are what the decoder needs of the v2 json package, which it can't import: the decoding by the methods which read a jsontext.Decoder, which the package sets.
Package-Level Constants (total 25)
DisallowUnknownFieldsOption makes an object key which matches no field of the struct an error.
NoCopyStringOption makes the decoded strings refer to the input instead of a copy of their bytes.
UseNumberOption decodes a number into interface{} as json.Number instead of float64.
V2AllowDuplicateNames lets an object have a name more than once.
V2AllowInvalidUTF8 lets the strings have invalid UTF-8, which is replaced by U+FFFD.
V2MatchCaseInsensitiveNames matches the names of an object with the names of the fields of a struct by their folded names too, unless a field has the `case:strict` option.
The options of the semantics of encoding/json which the v2 json package applies when unmarshaling, named by the options of the root package, whose documentation they follow, in the order of their properties in internal/options, from ParseBytesWithLooseRFC4648, so that they are copied at once ( see unmarshalFlags of the v2 json package ).
V2RejectUnknownMembers makes a name of an object which is the name of no field of a struct an error, unless the struct has an embedded fallback.
V2Semantics is set for every decoding of v2.
V2StringifyNumbers decodes the numbers of the numeric types from JSON strings, by decoders of their own.