Commit 462aa7ec authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

encoding/json: update docs to not use misuse the term "object"

In JSON terminology, "object" is a collect of key/value pairs. But a
JSON object is only one type of JSON value (others are string, number,
array, true, false, null).

This updates the Go docs (at least the public godoc) to not use
"object" when we mean any JSON value.

Change-Id: Ieb1c456c703693714d63d9d09d306f4d9e8f4597
Reviewed-on: https://go-review.googlesource.com/22003Reviewed-by: default avatarAndrew Gerrand <adg@golang.org>
parent 2cdcb6f8
...@@ -97,7 +97,7 @@ func Unmarshal(data []byte, v interface{}) error { ...@@ -97,7 +97,7 @@ func Unmarshal(data []byte, v interface{}) error {
return d.unmarshal(v) return d.unmarshal(v)
} }
// Unmarshaler is the interface implemented by objects // Unmarshaler is the interface implemented by types
// that can unmarshal a JSON description of themselves. // that can unmarshal a JSON description of themselves.
// The input can be assumed to be a valid encoding of // The input can be assumed to be a valid encoding of
// a JSON value. UnmarshalJSON must copy the JSON data // a JSON value. UnmarshalJSON must copy the JSON data
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// Package json implements encoding and decoding of JSON objects as defined in // Package json implements encoding and decoding of JSON as defined in
// RFC 4627. The mapping between JSON objects and Go values is described // RFC 4627. The mapping between JSON and Go values is described
// in the documentation for the Marshal and Unmarshal functions. // in the documentation for the Marshal and Unmarshal functions.
// //
// See "JSON and Go" for an introduction to this package: // See "JSON and Go" for an introduction to this package:
...@@ -52,7 +52,7 @@ import ( ...@@ -52,7 +52,7 @@ import (
// //
// Array and slice values encode as JSON arrays, except that // Array and slice values encode as JSON arrays, except that
// []byte encodes as a base64-encoded string, and a nil slice // []byte encodes as a base64-encoded string, and a nil slice
// encodes as the null JSON object. // encodes as the null JSON value.
// //
// Struct values encode as JSON objects. Each exported struct field // Struct values encode as JSON objects. Each exported struct field
// becomes a member of the object unless // becomes a member of the object unless
...@@ -121,10 +121,10 @@ import ( ...@@ -121,10 +121,10 @@ import (
// keys, subject to the UTF-8 coercion described for string values above. // keys, subject to the UTF-8 coercion described for string values above.
// //
// Pointer values encode as the value pointed to. // Pointer values encode as the value pointed to.
// A nil pointer encodes as the null JSON object. // A nil pointer encodes as the null JSON value.
// //
// Interface values encode as the value contained in the interface. // Interface values encode as the value contained in the interface.
// A nil interface value encodes as the null JSON object. // A nil interface value encodes as the null JSON value.
// //
// Channel, complex, and function values cannot be encoded in JSON. // Channel, complex, and function values cannot be encoded in JSON.
// Attempting to encode such a value causes Marshal to return // Attempting to encode such a value causes Marshal to return
...@@ -192,7 +192,7 @@ func HTMLEscape(dst *bytes.Buffer, src []byte) { ...@@ -192,7 +192,7 @@ func HTMLEscape(dst *bytes.Buffer, src []byte) {
} }
} }
// Marshaler is the interface implemented by objects that // Marshaler is the interface implemented by types that
// can marshal themselves into valid JSON. // can marshal themselves into valid JSON.
type Marshaler interface { type Marshaler interface {
MarshalJSON() ([]byte, error) MarshalJSON() ([]byte, error)
......
...@@ -10,7 +10,7 @@ import ( ...@@ -10,7 +10,7 @@ import (
"io" "io"
) )
// A Decoder reads and decodes JSON objects from an input stream. // A Decoder reads and decodes JSON values from an input stream.
type Decoder struct { type Decoder struct {
r io.Reader r io.Reader
buf []byte buf []byte
...@@ -164,7 +164,7 @@ func nonSpace(b []byte) bool { ...@@ -164,7 +164,7 @@ func nonSpace(b []byte) bool {
return false return false
} }
// An Encoder writes JSON objects to an output stream. // An Encoder writes JSON values to an output stream.
type Encoder struct { type Encoder struct {
w io.Writer w io.Writer
err error err error
...@@ -218,14 +218,14 @@ func (enc *Encoder) Encode(v interface{}) error { ...@@ -218,14 +218,14 @@ func (enc *Encoder) Encode(v interface{}) error {
return err return err
} }
// Indent sets the encoder to format each encoded object with Indent. // Indent sets the encoder to format each encoded value with Indent.
func (enc *Encoder) Indent(prefix, indent string) { func (enc *Encoder) Indent(prefix, indent string) {
enc.indentBuf = new(bytes.Buffer) enc.indentBuf = new(bytes.Buffer)
enc.indentPrefix = prefix enc.indentPrefix = prefix
enc.indentValue = indent enc.indentValue = indent
} }
// RawMessage is a raw encoded JSON object. // RawMessage is a raw encoded JSON value.
// It implements Marshaler and Unmarshaler and can // It implements Marshaler and Unmarshaler and can
// be used to delay JSON decoding or precompute a JSON encoding. // be used to delay JSON decoding or precompute a JSON encoding.
type RawMessage []byte type RawMessage []byte
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment