pkg.go.dev Open in urlscan Pro
2600:1901:0:f535::  Public Scan

Submitted URL: http://google.golang.org/protobuf/internal/encoding/json
Effective URL: https://pkg.go.dev/google.golang.org/protobuf/internal/encoding/json
Submission: On June 25 via api from US — Scanned from DE

Form analysis 3 forms found in the DOM

/search

<form class="go-InputGroup go-ShortcutKey go-SearchForm-form" action="/search" data-shortcut="/" data-shortcut-alt="search" data-gtmc="search form" aria-label="Search for a package" role="search">
  <input name="q" class="go-Input js-searchFocus" aria-label="Search for a package" type="search" autocapitalize="off" autocomplete="off" autocorrect="off" spellcheck="false" placeholder="Search packages or symbols" value="">
  <input name="m" value="" hidden="">
  <button class="go-Button go-Button--inverted" aria-label="Submit search">
    <img class="go-Icon" height="24" width="24" src="/static/shared/icon/search_gm_grey_24dp.svg" alt="">
  </button>
</form>

DIALOG

<form method="dialog" data-gmtc="jump to form" aria-label="Jump to Identifier">
  <div class="Dialog-title go-Modal-header">
    <h2>Jump to</h2>
    <button class="go-Button go-Button--inline" type="button" data-modal-close="" data-gtmc="modal button" aria-label="Close">
      <img class="go-Icon" height="24" width="24" src="/static/shared/icon/close_gm_grey_24dp.svg" alt="">
    </button>
  </div>
  <div class="JumpDialog-filter">
    <input class="JumpDialog-input go-Input" autocomplete="off" type="text">
  </div>
  <div class="JumpDialog-body go-Modal-body">
    <div class="JumpDialog-list"></div>
  </div>
  <div class="go-Modal-actions">
    <button class="go-Button" data-test-id="close-dialog">Close</button>
  </div>
</form>

DIALOG

<form method="dialog">
  <div class="go-Modal-header">
    <h2>Keyboard shortcuts</h2>
    <button class="go-Button go-Button--inline" type="button" data-modal-close="" data-gtmc="modal button" aria-label="Close">
      <img class="go-Icon" height="24" width="24" src="/static/shared/icon/close_gm_grey_24dp.svg" alt="">
    </button>
  </div>
  <div class="go-Modal-body">
    <table>
      <tbody>
        <tr>
          <td class="ShortcutsDialog-key">
            <strong>?</strong>
          </td>
          <td> : This menu</td>
        </tr>
        <tr>
          <td class="ShortcutsDialog-key">
            <strong>/</strong>
          </td>
          <td> : Search site</td>
        </tr>
        <tr>
          <td class="ShortcutsDialog-key">
            <strong>f</strong> or <strong>F</strong>
          </td>
          <td> : Jump to</td>
        </tr>
        <tr>
          <td class="ShortcutsDialog-key"><strong>y</strong> or <strong>Y</strong></td>
          <td> : Canonical URL</td>
        </tr>
      </tbody>
    </table>
  </div>
  <div class="go-Modal-actions">
    <button class="go-Button" data-test-id="close-dialog">Close</button>
  </div>
</form>

Text Content

Skip to Main Content
 * Why Go
   * Case Studies
     
     Common problems companies solve with Go
   
   * Use Cases
     
     Stories about how and why companies use Go
   
   * Security Policy
     
     How Go can help keep you secure by default
 * Learn
 * Docs
   * Effective Go
     
     Tips for writing clear, performant, and idiomatic Go code
   
   * Go User Manual
     
     A complete introduction to building software with Go
   
   * Standard library
     
     Reference documentation for Go's standard library
   
   * Release Notes
     
     Learn what's new in each Go release
 * Packages
 * Community
   * Recorded Talks
     
     Videos from prior events
   
   * Meetups
     
     Meet other local Go developers
   
   * Conferences
     
     Learn and network with Go developers from around the world
   
   * Go blog
     
     The Go project's official blog.
   
   * Go project
     
     Get help and stay informed from Go
   
   * Get connected
     
     
     
     

 * Why Go
   Why Go
    * Case Studies
    * Use Cases
    * Security Policy

 * Learn
 * Docs
   Docs
    * Effective Go
    * Go User Manual
    * Standard library
    * Release Notes

 * Packages
 * Community
   Community
    * Recorded Talks
    * Meetups
    * Conferences
    * Go blog
    * Go project
    * Get connected
      


 1. Discover Packages
 2. google.golang.org/protobuf
 3. internal
 4. encoding
 5. json


JSON

package
Version: v1.34.2
Opens a new window with list of versions in this module.
Latest Latest

This package is not in the latest version of its module.

Go to latest Published: Jun 11, 2024 License: BSD-3-Clause
Opens a new window with license information.
Imports: 14
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Main Versions Licenses Imports Imported By


DETAILS

 * Valid go.mod file
   
   The Go module system was introduced in Go 1.11 and is the official dependency
   management solution for Go.

 * Redistributable license
   
   Redistributable licenses place minimal restrictions on how software can be
   used, modified, and redistributed.

 * Tagged version
   
   Modules with tagged versions give importers more predictable builds.

 * Stable version
   
   When a project reaches major version v1 it is considered stable.

 * Learn more about best practices


REPOSITORY

github.com/protocolbuffers/protobuf-go


LINKS

 * Open Source Insights

Jump to ...
 * Documentation
   * Index
   * Constants
   * Variables
   * Functions
     * TokenEquals(x, y)
   * Types
     * type Decoder
       * NewDecoder(b)
       * (d) Clone()
       * (d) Peek()
       * (d) Position(idx)
       * (d) Read()
     * type Encoder
       * NewEncoder(buf, indent)
       * (e) Bytes()
       * (e) EndArray()
       * (e) EndObject()
       * (e) StartArray()
       * (e) StartObject()
       * (e) WriteBool(b)
       * (e) WriteFloat(n, bitSize)
       * (e) WriteInt(n)
       * (e) WriteName(s)
       * (e) WriteNull()
       * (e) WriteString(s)
       * (e) WriteUint(n)
     * type Kind
       * (k) String()
     * type Token
       * (t) Bool()
       * (t) Float(bitSize)
       * (t) Int(bitSize)
       * (t) Kind()
       * (t) Name()
       * (t) ParsedString()
       * (t) Pos()
       * (t) RawString()
       * (t) Uint(bitSize)
 * Source Files

DocumentationSource FilesIndexConstantsVariablesFunctionsTypesTokenEquals(x,
y)type Decodertype Encodertype Kindtype TokenNewDecoder(b)(d) Clone()(d)
Peek()(d) Position(idx)(d) Read()NewEncoder(buf, indent)(e) Bytes()(e)
EndArray()(e) EndObject()(e) StartArray()(e) StartObject()(e) WriteBool(b)(e)
WriteFloat(n, bitSize)(e) WriteInt(n)(e) WriteName(s)(e) WriteNull()(e)
WriteString(s)(e) WriteUint(n)(k) String()(t) Bool()(t) Float(bitSize)(t)
Int(bitSize)(t) Kind()(t) Name()(t) ParsedString()(t) Pos()(t) RawString()(t)
Uint(bitSize)


DOCUMENTATION ¶


INDEX ¶

 * Variables
 * func TokenEquals(x, y Token) bool
 * type Decoder
 * * func NewDecoder(b []byte) *Decoder
 * * func (d *Decoder) Clone() *Decoder
   * func (d *Decoder) Peek() (Token, error)
   * func (d *Decoder) Position(idx int) (line int, column int)
   * func (d *Decoder) Read() (Token, error)
 * type Encoder
 * * func NewEncoder(buf []byte, indent string) (*Encoder, error)
 * * func (e *Encoder) Bytes() []byte
   * func (e *Encoder) EndArray()
   * func (e *Encoder) EndObject()
   * func (e *Encoder) StartArray()
   * func (e *Encoder) StartObject()
   * func (e *Encoder) WriteBool(b bool)
   * func (e *Encoder) WriteFloat(n float64, bitSize int)
   * func (e *Encoder) WriteInt(n int64)
   * func (e *Encoder) WriteName(s string) error
   * func (e *Encoder) WriteNull()
   * func (e *Encoder) WriteString(s string) error
   * func (e *Encoder) WriteUint(n uint64)
 * type Kind
 * * func (k Kind) String() string
 * type Token
 * * func (t Token) Bool() bool
   * func (t Token) Float(bitSize int) (float64, bool)
   * func (t Token) Int(bitSize int) (int64, bool)
   * func (t Token) Kind() Kind
   * func (t Token) Name() string
   * func (t Token) ParsedString() string
   * func (t Token) Pos() int
   * func (t Token) RawString() string
   * func (t Token) Uint(bitSize int) (uint64, bool)


CONSTANTS ¶

This section is empty.


VARIABLES ¶

View Source

var ErrUnexpectedEOF = errors.New("%v", io.ErrUnexpectedEOF)

ErrUnexpectedEOF means that EOF was encountered in the middle of the input.


FUNCTIONS ¶

FUNC TOKENEQUALS ¶

func TokenEquals(x, y Token) bool

TokenEquals returns true if given Tokens are equal, else false.


TYPES ¶

TYPE DECODER ¶

type Decoder struct {
	// contains filtered or unexported fields
}

Decoder is a token-based JSON decoder.

FUNC NEWDECODER ¶

func NewDecoder(b []byte) *Decoder

NewDecoder returns a Decoder to read the given []byte.

FUNC (*DECODER) CLONE ¶

func (d *Decoder) Clone() *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.

FUNC (*DECODER) PEEK ¶

func (d *Decoder) Peek() (Token, error)

Peek looks ahead and returns the next token kind without advancing a read.

FUNC (*DECODER) POSITION ¶

func (d *Decoder) Position(idx int) (line int, column int)

Position returns line and column number of given index of the original input. It
will panic if index is out of range.

FUNC (*DECODER) READ ¶

func (d *Decoder) Read() (Token, error)

Read returns the next JSON token. It will return an error if there is no valid
token.

TYPE ENCODER ¶

type Encoder struct {
	// contains filtered or unexported fields
}

Encoder provides methods to write out JSON constructs and values. The user is
responsible for producing valid sequences of JSON constructs and values.

FUNC NEWENCODER ¶

func NewEncoder(buf []byte, indent string) (*Encoder, error)

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.

FUNC (*ENCODER) BYTES ¶

func (e *Encoder) Bytes() []byte

Bytes returns the content of the written bytes.

FUNC (*ENCODER) ENDARRAY ¶

func (e *Encoder) EndArray()

EndArray writes out the ']' symbol.

FUNC (*ENCODER) ENDOBJECT ¶

func (e *Encoder) EndObject()

EndObject writes out the '}' symbol.

FUNC (*ENCODER) STARTARRAY ¶

func (e *Encoder) StartArray()

StartArray writes out the '[' symbol.

FUNC (*ENCODER) STARTOBJECT ¶

func (e *Encoder) StartObject()

StartObject writes out the '{' symbol.

FUNC (*ENCODER) WRITEBOOL ¶

func (e *Encoder) WriteBool(b bool)

WriteBool writes out the given boolean value.

FUNC (*ENCODER) WRITEFLOAT ¶

func (e *Encoder) WriteFloat(n float64, bitSize int)

WriteFloat writes out the given float and bitSize in JSON number value.

FUNC (*ENCODER) WRITEINT ¶

func (e *Encoder) WriteInt(n int64)

WriteInt writes out the given signed integer in JSON number value.

FUNC (*ENCODER) WRITENAME ¶

func (e *Encoder) WriteName(s string) error

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.

FUNC (*ENCODER) WRITENULL ¶

func (e *Encoder) WriteNull()

WriteNull writes out the null value.

FUNC (*ENCODER) WRITESTRING ¶

func (e *Encoder) WriteString(s string) error

WriteString writes out the given string in JSON string value. Returns error if
input string contains invalid UTF-8.

FUNC (*ENCODER) WRITEUINT ¶

func (e *Encoder) WriteUint(n uint64)

WriteUint writes out the given unsigned integer in JSON number value.

TYPE KIND ¶

type Kind uint16

Kind represents a token kind expressible in the JSON format.

const (
	Invalid Kind = (1 << iota) / 2
	EOF
	Null
	Bool
	Number
	String
	Name
	ObjectOpen
	ObjectClose
	ArrayOpen
	ArrayClose
)

FUNC (KIND) STRING ¶

func (k Kind) String() string

TYPE TOKEN ¶

type Token struct {
	// contains filtered or unexported fields
}

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.

FUNC (TOKEN) BOOL ¶

func (t Token) Bool() bool

Bool returns the bool value if token kind is Bool, else it panics.

FUNC (TOKEN) FLOAT ¶

func (t Token) Float(bitSize int) (float64, bool)

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.

FUNC (TOKEN) INT ¶

func (t Token) Int(bitSize int) (int64, bool)

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.

FUNC (TOKEN) KIND ¶

func (t Token) Kind() Kind

Kind returns the token kind.

FUNC (TOKEN) NAME ¶

func (t Token) Name() string

Name returns the object name if token is Name, else it panics.

FUNC (TOKEN) PARSEDSTRING ¶

func (t Token) ParsedString() string

ParsedString returns the string value for a JSON string token or the read value
in string if token is not a string.

FUNC (TOKEN) POS ¶

func (t Token) Pos() int

Pos returns the token position from the input.

FUNC (TOKEN) RAWSTRING ¶

func (t Token) RawString() string

RawString returns the read value in string.

FUNC (TOKEN) UINT ¶

func (t Token) Uint(bitSize int) (uint64, bool)

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.


SOURCE FILES ¶

View all Source files
 * decode.go
 * decode_number.go
 * decode_string.go
 * decode_token.go
 * encode.go

Click to show internal directories.
Click to hide internal directories.

Why Go Use Cases Case Studies
Get Started Playground Tour Stack Overflow Help
Packages Standard Library Sub-repositories About Go Packages
About Download Blog Issue Tracker Release Notes Brand Guidelines Code of Conduct
Connect Twitter GitHub Slack r/golang Meetup Golang Weekly
 * Copyright
 * Terms of Service
 * Privacy Policy
 * Report an Issue

 * Theme Toggle

 * Shortcuts Modal


JUMP TO



Close


KEYBOARD SHORTCUTS

? : This menu / : Search site f or F : Jump to y or Y : Canonical URL

Close
go.dev uses cookies from Google to deliver and enhance the quality of its
services and to analyze traffic. Learn more.
Okay