Package-Level Type Names (total 7, in which 4 are exported)
/* sort exporteds by: | */
Decoder is a token-based JSON decoder.
in contains the unconsumed input.
lastCall is last method called, either readCall or peekCall.
Initial value is readCall.
lastErr contains the last read error.
lastToken contains the last read token.
openStack is a stack containing ObjectOpen and ArrayOpen values. The
top of stack represents the object or the array the current value is
directly located in.
orig is used in reporting line and column.
Clone returns a copy of the Decoder for use in reading ahead the next JSON
object, array or other values without affecting current Decoder.
Peek looks ahead and returns the next token kind without advancing a read.
Position returns line and column number of given index of the original input.
It will panic if index is out of range.
Read returns the next JSON token.
It will return an error if there is no valid token.
consume consumes n bytes of input and any subsequent whitespace.
consumeBoolToken constructs a Token for a Bool kind with raw value derived from
current d.in and given size.
consumeStringToken constructs a Token for a String kind with raw value derived
from current d.in and given size.
consumeToken constructs a Token for given Kind with raw value derived from
current d.in and given size, and consumes the given size-lenght of it.
currPos returns the current index position of d.in from d.orig.
isValueNext returns true if next type should be a JSON value: Null,
Number, String or Bool.
newSyntaxError returns an error with line and column information useful for
syntax errors.
parseNext parses for the next JSON token. It returns a Token object for
different types, except for Name. It does not handle whether the next token
is in a valid sequence or not.
(*Decoder) parseString(in []byte) (string, int, error)
func NewDecoder(b []byte) *Decoder
func (*Decoder).Clone() *Decoder
Encoder provides methods to write out JSON constructs and values. The user is
responsible for producing valid sequences of JSON constructs and values.
indentstringindents[]bytelastKindkindout[]byte
Bytes returns the content of the written bytes.
EndArray writes out the ']' symbol.
EndObject writes out the '}' symbol.
StartArray writes out the '[' symbol.
StartObject writes out the '{' symbol.
WriteBool writes out the given boolean value.
WriteFloat writes out the given float and bitSize in JSON number value.
WriteInt writes out the given signed integer in JSON number value.
WriteName writes out the given string in JSON string value and the name
separator ':'. Returns error if input string contains invalid UTF-8, which
should not be likely as protobuf field names should be valid.
WriteNull writes out the null value.
WriteString writes out the given string in JSON string value. Returns error
if input string contains invalid UTF-8.
WriteUint writes out the given unsigned integer in JSON number value.
prepareNext adds possible comma and indentation for the next value based
on last type and indent option. It also updates lastKind to next.
func NewEncoder(indent string) (*Encoder, error)
Token provides a parsed token kind and value.
Values are provided by the difference accessor methods. The accessor methods
Name, Bool, and ParsedString will panic if called on the wrong kind. There
are different accessor methods for the Number kind for converting to the
appropriate Go numeric type and those methods have the ok return value.
boo is parsed boolean value.
Token kind.
pos provides the position of the token in the original input.
raw bytes of the serialized token.
This is a subslice into the original input.
str is parsed string value.
Bool returns the bool value if token kind is Bool, else it panics.
Float returns the floating-point number if token kind is Number.
The floating-point precision is specified by the bitSize parameter: 32 for
float32 or 64 for float64. If bitSize=32, the result still has type float64,
but it will be convertible to float32 without changing its value. It will
return false if the number exceeds the floating point limits for given
bitSize.
Int returns the signed integer number if token is Number.
The given bitSize specifies the integer type that the result must fit into.
It returns false if the number is not an integer value or if the result
exceeds the limits for given bitSize.
Kind returns the token kind.
Name returns the object name if token is Name, else it panics.
ParsedString returns the string value for a JSON string token or the read
value in string if token is not a string.
Pos returns the token position from the input.
RawString returns the read value in string.
Uint returns the signed integer number if token is Number.
The given bitSize specifies the unsigned integer type that the result must
fit into. It returns false if the number is not an unsigned integer value
or if the result exceeds the limits for given bitSize.
( Token) getIntStr() (string, bool)
func (*Decoder).Peek() (Token, error)
func (*Decoder).Read() (Token, error)
func (*Decoder).consumeBoolToken(b bool, size int) Token
func (*Decoder).consumeStringToken(s string, size int) Token
func (*Decoder).consumeToken(kind Kind, size int) Token
func (*Decoder).parseNext() (Token, error)
func google.golang.org/protobuf/encoding/protojson.findTypeURL(d protojson.decoder) (Token, error)
func TokenEquals(x, y Token) bool
func google.golang.org/protobuf/encoding/protojson.getFloat(tok Token, bitSize int) (protoreflect.Value, bool)
func google.golang.org/protobuf/encoding/protojson.getInt(tok Token, bitSize int) (protoreflect.Value, bool)
func google.golang.org/protobuf/encoding/protojson.getUint(tok Token, bitSize int) (protoreflect.Value, bool)
func google.golang.org/protobuf/encoding/protojson.unmarshalBytes(tok Token) (protoreflect.Value, bool)
func google.golang.org/protobuf/encoding/protojson.unmarshalEnum(tok Token, fd protoreflect.FieldDescriptor) (protoreflect.Value, bool)
func google.golang.org/protobuf/encoding/protojson.unmarshalFloat(tok Token, bitSize int) (protoreflect.Value, bool)
func google.golang.org/protobuf/encoding/protojson.unmarshalInt(tok Token, bitSize int) (protoreflect.Value, bool)
func google.golang.org/protobuf/encoding/protojson.unmarshalUint(tok Token, bitSize int) (protoreflect.Value, bool)
call specifies which Decoder method was invoked.
const peekCall
const readCall
Package-Level Functions (total 12, in which 3 are exported)
NewDecoder returns a Decoder to read the given []byte.
NewEncoder returns an Encoder.
If indent is a non-empty string, it causes every entry for an Array or Object
to be preceded by the indent and trailed by a newline.
TokenEquals returns true if given Tokens are equal, else false.
appendFloat formats given float in bitSize, and appends to the given []byte.
indexNeedEscapeInBytes returns the index of the character that needs
escaping. If no characters need escaping, this returns the input length.
indexNeedEscapeInString returns the index of the character that needs
escaping. If no characters need escaping, this returns the input length.
isNotDelim returns true if given byte is a not delimiter character.
matchWithDelim matches s with the input b and verifies that the match
terminates with a delimiter of some form (e.g., r"[^-+_.a-zA-Z0-9]").
As a special case, EOF is considered a delimiter. It returns the length of s
if there is a match, else 0.
normalizeToIntString returns an integer string in normal form without the
E-notation for given numberParts. It will return false if it is not an
integer or if the exponent exceeds than max/min int value.
parseNumber reads the given []byte for a valid JSON number. If it is valid,
it returns the number of bytes. Parsing logic follows the definition in
https://tools.ietf.org/html/rfc7159#section-6, and is based off
encoding/json.isValidNumber function.
parseNumber constructs numberParts from given []byte. The logic here is
similar to consumeNumber above with the difference of having to construct
numberParts. The slice fields in numberParts are subslices of the input.
Package-Level Variables (total 3, in which 1 are exported)
ErrUnexpectedEOF means that EOF was encountered in the middle of the input.
Sentinel error used for indicating invalid UTF-8.
Any sequence that looks like a non-delimiter (for error reporting).
Package-Level Constants (total 21, in which 11 are exported)