package json

Import Path
	google.golang.org/protobuf/internal/encoding/json (on go.dev)

Dependency Relation
	imports 14 packages, and imported by one package


Package-Level Type Names (total 7, in which 4 are exported)
/* sort exporteds by: | */
Decoder is a token-based JSON decoder. 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. 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. 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. func NewEncoder(indent string) (*Encoder, error)
Kind represents a token kind expressible in the JSON format. ( Kind) String() string Kind : expvar.Var Kind : fmt.Stringer func Token.Kind() Kind const ArrayClose const ArrayOpen const Bool const EOF const Invalid const Name const Null const Number const ObjectClose const ObjectOpen const String
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. 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. func (*Decoder).Peek() (Token, error) func (*Decoder).Read() (Token, error) func TokenEquals(x, y Token) bool
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.
Package-Level Variables (total 3, in which 1 are exported)
ErrUnexpectedEOF means that EOF was encountered in the middle of the input.
Package-Level Constants (total 21, in which 11 are exported)