package textcoder
Import Path
github.com/goccy/go-json/internal/textcoder (on go.dev)
Dependency Relation
imports 3 packages, and imported by 3 packages
Involved Source Files
Package textcoder lets the v2 json package give a jsontext.Encoder to a method or a function of marshaling,
which writes after the output of the encoder of the v2 semantics: jsontext sets these functions, which take its
encoder as an any, since this package can't import jsontext.
Package-Level Type Names (total 5)
Attachment is the place of the output where an encoder is attached ( see Attach ), and, after Attach and Detach,
where it is.
Base int64
Count int64
Depth int
Failed is the error of a call which failed at the encoder, which Detach sets ( see Fail ).
Object and Count are the innermost level of the place, an open object or array, or the top level if Top is
set: Count has the parity of the place, a value or a name, and is 0 only if the level has no token yet. The
levels around it, and its name and count, Outer gives when the encoder needs them.
Opts are the options of the encoder, which are the ones it was attached with the last time if Same is set.
Out is the output before the place, at the offset Base of the whole output, or, if Out is empty, Base is
the offset of the value after its delimiter: the delimiter which the encoder writes before the value, whose
length Attach sets in Skip, is not a part of the output then, which the caller writes to another encoder.
Outer Outer
OuterDepth is the number of the arrays and the objects which are open around the place in the whole output,
which the encoder counts its levels after: it fails to begin one past the deepest level, as the encoder of the
whole output does.
Same bool
Skip, and Depth and Count of the innermost level, which Detach sets after the writes, Attach sets.
Top bool
DecoderAttachment is the place of the input where a decoder is attached ( see AttachDecoder ), and, after
AttachDecoder and DetachDecoder, where it stopped reading.
Base int64
Count int64
Depth and Count of the innermost level, Pos, End, the offset in the whole input where the decoder stopped
reading, and PrevStart, the one of the start of the last token or value which was read, DetachDecoder sets
after the reads; Depth is the one of the place after AttachDecoder. If the decoder read R, Rest is what it
read and didn't use, which follows End, and Pos is not a place of In.
End int64
In is the input which the decoder reads from Pos: the end of the token before the value, so that it reads the
delimiter before the value as its own. In[0] is at the offset Base of the whole input, which the offsets of
the decoder count from. R is the reader of the input after In, which the decoder reads when it needs more, or
nil if In has all of it: the whole input of the call, or of the value. If Own is set, In is a buffer of the
caller, which the decoder moves its input in and reads into, rather than one it makes, and which is In after
DetachDecoder, grown if the decoder needed more room, for the next attach.
Object and Count are the innermost level of the place, an open object or array, or the top level if Top is
set: Count has the parity of the place, which is a value, and is 0 only if the level has no token before
it. The levels around it, and its name and its count, Outer gives when the decoder needs them.
Opts are the options of the decoder, which are the ones it was attached with the last time if Same is set.
Outer Outer
OuterDepth is the number of the arrays and the objects which are open around the place in the whole input,
which the decoder counts its levels after: it fails to begin one past the deepest level, as the decoder of
the whole input does.
Own bool
Pos int
PrevStart int64
R io.Reader
Rest []byte
Same bool
Top bool
Level is a level of the output: the top level, or an open object or array.
Count is the number of the tokens of the level written before the value of the next level, which is open,
or, at the innermost level, before the next token: the elements of an array, the names and the values of an
object.
Name is the last name of an object, unquoted: of the value which is open or next, if Count is odd. The names
before it are not kept: a method writes a single value, which is checked for duplicate names in itself, and
the place of a value is the last name of each object. It is nil where the level has no name, and empty but
not nil for the name "".
Object bool
func Outer.Levels() []Level
func github.com/goccy/go-json/internal/decoder.(*Stream).BeginV2At(r io.Reader, levels []Level) []Level
func github.com/goccy/go-json/internal/decoder.(*Stream).RestorePath(saved []Level) []Level
func github.com/goccy/go-json/internal/decoder.(*Stream).SetPath(path, levels []Level) []Level
func github.com/goccy/go-json/internal/decoder.(*Stream).BeginV2At(r io.Reader, levels []Level) []Level
func github.com/goccy/go-json/internal/decoder.(*Stream).RestorePath(saved []Level) []Level
func github.com/goccy/go-json/internal/decoder.(*Stream).SetPath(path, levels []Level) []Level
Outer gives the levels of the place where an encoder was attached, the top level first ( see Attach ): they are
found only when the encoder needs them, for a JSON pointer or the stack, which most writes don't.
( Outer) Levels() []Level
Read is how UnmarshalPlace reads the value which it stops at.
const ReadNothing
const ReadToken
const ReadValue
Package-Level Variables (total 31)
AfterTopLevelError returns the syntax error of the first byte of in, at the offset base of the input, which follows
the top-level value, as jsontext reports it.
Attach makes enc, a *jsontext.Encoder, write after the output of the place p by its options ( see
Attachment ).
enc is the pointer itself, without the check of a type assertion, which the calls for every value of a
method don't take; the place is given by a pointer, as its fields don't fit the registers of a call.
AttachDecoder makes dec, a *jsontext.Decoder, read the input of the place p by its options ( see
DecoderAttachment ).
BeginValue reads what dec reads before its next value, which is not a name, as ReadValue reads it: the
white space and the delimiter, which it checks, and returns the offset of the value in the whole input, or
the error which ReadValue returns there, io.EOF after the last value of the input. The value isn't read.
Configure makes enc write by the options until restore is called, which gives it back its own, with the
strings of the values as they are, which the calls which wrote them escaped.
ConfigureDecoder makes the Decoder at dec read by the options of opts, which are its own and the ones of a call,
until restore is called, which gives it back its own.
DecoderAt returns the rest of the place of the next value of dec: whether it is a name of an object, the Outer
of the attach of dec, or nil, and the number of the arrays and the objects open around it.
DecoderBuffer returns the buffer of dec, which its input up to len(buf) has been read into, and the offset of
its first byte in the whole input. It reports false if a caller can't read the buffer in place and read more
into it ( see FetchInput ): the array of a bytes.Buffer, of a decoder of a bytes.Buffer, which the decoder
doesn't own, or a buffer without InputRoom bytes of room after its input, which a decoder of a reader leaves
it.
DecoderFailed reports whether FailDecoder made every read of dec fail.
DecoderInput returns the input of dec from the offset start of the whole input, which its buffer has: the
bytes of its buffer, and its reader, which reads the input after them.
DecoderPlace returns the levels of the whole input around the next value of dec, the top level first, appended
to levels ( see Level ), whose names are copied into the arrays of the names of the entries of levels after its
length, which are reused.
DecoderPointer returns the JSON pointer of the place of dec, which DetachDecoder detached, which where points
to: the last value which was read (-1), the next value (+1), or the level it is in (0).
Detach sets the output of enc, which Attach set up, and its depth and the count of the tokens of its
innermost level in p.
DetachDecoder sets where dec, which AttachDecoder set up, stopped reading in p, and drops its input: a
decoder kept past its call reads nothing more.
EndValue makes dec go on after the next value, which was read from start to end, offsets of the whole
input: in its buffer, which may have dropped the start of the value for a caller which read more into it
( see FetchInput ), or, if rest is set, from rest, the input after the value which was read from its reader,
which it copies. The value is the last value which dec read, from start, whose place a decoder attached at a
value reports to the caller ( see DetachDecoder ).
Fail records err in enc, an encoder which Attach attached, the first error of a call of MarshalEncode which
failed at it: the value which enc was given the place of fails with it, whatever its method returns.
FailDecoder makes every later read of dec fail with err, which the read returns as it is.
FetchInput reads more of the input of dec into its buffer, which DecoderBuffer gave a caller, after what has
been read, n bytes at most, by one read of its reader, keeping the bytes from the offset keep of the whole
input, which the buffer may move to its start, and returns the buffer as DecoderBuffer does, the number of
the bytes read and the error of the read, which dec doesn't keep. The state of dec is the caller's until it
ends the value by EndValue, with the rest, or PutBack.
Invalidate makes enc fail every write until a Reset: MarshalEncode stopped within an object or an array it
opened.
ReadError returns err, the error of a reader of the input, as jsontext reports it, and IsIOError reports whether
err is the error of a reader or of a writer, which a method passes on as it is.
Place returns the innermost level of enc, whose count may be the one which Attach was given ( see Attach ),
whether it is the top level, the offset in its output where its next value starts, the Outer which it was
attached with, if it was, and the number of the arrays and the objects open around its next value in the whole
output ( see Attachment.OuterDepth ).
Position returns the levels of enc, a *jsontext.Encoder, the top level first, and the offset in its output
where its next value starts: after the delimiter and the white space before it.
PutBack makes dec read in, the input from the offset start of the whole input, which a caller read from its
reader, as the next input: dec is where it was before its next value, which the caller didn't decode.
ReadError returns err, the error of a reader of the input, as jsontext reports it, and IsIOError reports whether
err is the error of a reader or of a writer, which a method passes on as it is.
ReleaseDecoder drops the options of dec, which it was attached with, and its outer levels: the decoder, which
is kept for the next call, must not keep the functions of the caller.
A skipper is a scanner of jsontext which reads the values that a call of the v2 json package skips, by the options
of the names of an object twice and of invalid UTF-8, without writing them: TakeSkipper returns one, which the
call keeps for all its values, and ReleaseSkipper puts it back.
ValidValue reports whether v, a JSON value valid by the grammar, has the text which jsontext reads by the options
of the skipper: valid UTF-8 unless invalid UTF-8 is allowed, and no object with a name twice unless that is.
SkipToEnd reads the input of the place p as UnmarshalPlaceAt reads it, up to the end of the value of the
level of the place at depth, which has count tokens before the value: the levels deeper are read to their
ends. It returns the offset of the end of the value, and what it read from the reader of p and didn't use,
or the error of the input.
A skipper is a scanner of jsontext which reads the values that a call of the v2 json package skips, by the options
of the names of an object twice and of invalid UTF-8, without writing them: TakeSkipper returns one, which the
call keeps for all its values, and ReleaseSkipper puts it back.
ValidValue reports whether v, a JSON value valid by the grammar, has the text which jsontext reads by the options
of the skipper: valid UTF-8 unless invalid UTF-8 is allowed, and no object with a name twice unless that is.
UnmarshalPlace reads in, the input of an unmarshaling of the v2 json package, by the options, as
encoding/json/v2 reads it, up to the value which starts at stop, which it reads as read says: it returns the
syntax error it meets first, a *jsontext.SyntacticError, or else the JSON pointer of the value. With stop -1,
it reads the whole input and returns its first syntax error, or nil if it has none.
UnmarshalPlaceAt is UnmarshalPlace for a part of the input, p.In, which is read from the place p as a decoder
attached there reads it ( see DecoderAttachment ), with the offsets of the whole input: it reads up to the value
which starts at the offset stop, or, with stop -1, up to the first syntax error, and returns "" and nil if In
ends before either. The levels of the place may end in the part, as no method reads it.
A skipper is a scanner of jsontext which reads the values that a call of the v2 json package skips, by the options
of the names of an object twice and of invalid UTF-8, without writing them: TakeSkipper returns one, which the
call keeps for all its values, and ReleaseSkipper puts it back.
ValidValue reports whether v, a JSON value valid by the grammar, has the text which jsontext reads by the options
of the skipper: valid UTF-8 unless invalid UTF-8 is allowed, and no object with a name twice unless that is.
Package-Level Constants (total 4)
InputRoom is the room which a decoder of a reader leaves after the input in its buffer, for a stream of the decoders
of v2 which reads the buffer in place ( see DecoderBuffer ): the padding which the stream keeps after the input in
its own buffer, for the nul byte after the input and a block of 64 bytes which a scan reads from any byte of the
input, past it from the last bytes.
ReadNothing reads nothing of the value.
ReadToken reads the first token of the value: all of it but for an object or an array.
ReadValue reads the whole value.
![]() |
The pages are generated with Golds v0.8.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |