mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
encoding/json/jsontext: consistently use JSON terminology
RFC 8259, section 2 uses the term "begin-array" amd "begin-object" rather than "start array" or "start object". Be consistent in our documentation. Change-Id: I172eb354c5e64b84c74bd662b1e581424e719a32 Reviewed-on: https://go-review.googlesource.com/c/go/+/683155 Auto-Submit: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
This commit is contained in:
parent
456a90aa16
commit
4506796a6e
4 changed files with 10 additions and 10 deletions
|
|
@ -25,8 +25,8 @@
|
||||||
// - a JSON literal (i.e., null, true, or false)
|
// - a JSON literal (i.e., null, true, or false)
|
||||||
// - a JSON string (e.g., "hello, world!")
|
// - a JSON string (e.g., "hello, world!")
|
||||||
// - a JSON number (e.g., 123.456)
|
// - a JSON number (e.g., 123.456)
|
||||||
// - a start or end delimiter for a JSON object (i.e., '{' or '}')
|
// - a begin or end delimiter for a JSON object (i.e., '{' or '}')
|
||||||
// - a start or end delimiter for a JSON array (i.e., '[' or ']')
|
// - a begin or end delimiter for a JSON array (i.e., '[' or ']')
|
||||||
//
|
//
|
||||||
// A JSON token is represented by the [Token] type in Go. Technically,
|
// A JSON token is represented by the [Token] type in Go. Technically,
|
||||||
// there are two additional structural characters (i.e., ':' and ','),
|
// there are two additional structural characters (i.e., ':' and ','),
|
||||||
|
|
|
||||||
|
|
@ -713,7 +713,7 @@ func (e *encoderState) reformatValue(dst []byte, src Value, depth int) ([]byte,
|
||||||
// appends it to the end of src, reformatting whitespace and strings as needed.
|
// appends it to the end of src, reformatting whitespace and strings as needed.
|
||||||
// It returns the extended dst buffer and the number of consumed input bytes.
|
// It returns the extended dst buffer and the number of consumed input bytes.
|
||||||
func (e *encoderState) reformatObject(dst []byte, src Value, depth int) ([]byte, int, error) {
|
func (e *encoderState) reformatObject(dst []byte, src Value, depth int) ([]byte, int, error) {
|
||||||
// Append object start.
|
// Append object begin.
|
||||||
if len(src) == 0 || src[0] != '{' {
|
if len(src) == 0 || src[0] != '{' {
|
||||||
panic("BUG: reformatObject must be called with a buffer that starts with '{'")
|
panic("BUG: reformatObject must be called with a buffer that starts with '{'")
|
||||||
} else if depth == maxNestingDepth+1 {
|
} else if depth == maxNestingDepth+1 {
|
||||||
|
|
@ -824,7 +824,7 @@ func (e *encoderState) reformatObject(dst []byte, src Value, depth int) ([]byte,
|
||||||
// appends it to the end of dst, reformatting whitespace and strings as needed.
|
// appends it to the end of dst, reformatting whitespace and strings as needed.
|
||||||
// It returns the extended dst buffer and the number of consumed input bytes.
|
// It returns the extended dst buffer and the number of consumed input bytes.
|
||||||
func (e *encoderState) reformatArray(dst []byte, src Value, depth int) ([]byte, int, error) {
|
func (e *encoderState) reformatArray(dst []byte, src Value, depth int) ([]byte, int, error) {
|
||||||
// Append array start.
|
// Append array begin.
|
||||||
if len(src) == 0 || src[0] != '[' {
|
if len(src) == 0 || src[0] != '[' {
|
||||||
panic("BUG: reformatArray must be called with a buffer that starts with '['")
|
panic("BUG: reformatArray must be called with a buffer that starts with '['")
|
||||||
} else if depth == maxNestingDepth+1 {
|
} else if depth == maxNestingDepth+1 {
|
||||||
|
|
|
||||||
|
|
@ -297,7 +297,7 @@ func (m *stateMachine) appendNumber() error {
|
||||||
return m.appendLiteral()
|
return m.appendLiteral()
|
||||||
}
|
}
|
||||||
|
|
||||||
// pushObject appends a JSON start object token as next in the sequence.
|
// pushObject appends a JSON begin object token as next in the sequence.
|
||||||
// If an error is returned, the state is not mutated.
|
// If an error is returned, the state is not mutated.
|
||||||
func (m *stateMachine) pushObject() error {
|
func (m *stateMachine) pushObject() error {
|
||||||
switch {
|
switch {
|
||||||
|
|
@ -332,7 +332,7 @@ func (m *stateMachine) popObject() error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// pushArray appends a JSON start array token as next in the sequence.
|
// pushArray appends a JSON begin array token as next in the sequence.
|
||||||
// If an error is returned, the state is not mutated.
|
// If an error is returned, the state is not mutated.
|
||||||
func (m *stateMachine) pushArray() error {
|
func (m *stateMachine) pushArray() error {
|
||||||
switch {
|
switch {
|
||||||
|
|
|
||||||
|
|
@ -33,8 +33,8 @@ var errInvalidToken = errors.New("invalid jsontext.Token")
|
||||||
// - a JSON literal (i.e., null, true, or false)
|
// - a JSON literal (i.e., null, true, or false)
|
||||||
// - a JSON string (e.g., "hello, world!")
|
// - a JSON string (e.g., "hello, world!")
|
||||||
// - a JSON number (e.g., 123.456)
|
// - a JSON number (e.g., 123.456)
|
||||||
// - a start or end delimiter for a JSON object (i.e., { or } )
|
// - a begin or end delimiter for a JSON object (i.e., { or } )
|
||||||
// - a start or end delimiter for a JSON array (i.e., [ or ] )
|
// - a begin or end delimiter for a JSON array (i.e., [ or ] )
|
||||||
//
|
//
|
||||||
// A Token cannot represent entire array or object values, while a [Value] can.
|
// A Token cannot represent entire array or object values, while a [Value] can.
|
||||||
// There is no Token to represent commas and colons since
|
// There is no Token to represent commas and colons since
|
||||||
|
|
@ -481,9 +481,9 @@ func (t Token) Kind() Kind {
|
||||||
// - 't': true
|
// - 't': true
|
||||||
// - '"': string
|
// - '"': string
|
||||||
// - '0': number
|
// - '0': number
|
||||||
// - '{': object start
|
// - '{': object begin
|
||||||
// - '}': object end
|
// - '}': object end
|
||||||
// - '[': array start
|
// - '[': array begin
|
||||||
// - ']': array end
|
// - ']': array end
|
||||||
//
|
//
|
||||||
// An invalid kind is usually represented using 0,
|
// An invalid kind is usually represented using 0,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue