Documentation
¶
Overview ¶
Package json wraps encoding/json as a codec.Codec implementation registered under Format("json"). Blank-importing this package is enough to make JSON resolvable via the core/data/codec registry.
It also re-exports the JSON appenders of internal/kernel/jsonenc — AppendString, AppendEscaped, AppendInt, AppendUint, BeginObject and the Object it returns — for the programs that write a JSON document by hand and want the escaping the SDK's own emitters use (ADR 0186 §D10). They register no codec and read no value by reflection; Marshal is still encoding/json, and does not change. A string is escaped as encoding/json escapes it, except that '<', '>' and '&' are NOT.
Package json — adapts *encoding/json.Decoder to codec.Decoder.
Package json — adapts *encoding/json.Encoder to codec.Encoder.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Codec codec.Codec = codec.Register(&jsonCodec{})
Codec is the JSON singleton, registered with core/data/codec at package load. Binding the registration result to a named var is more idiomatic than `var _ = codec.Register(...)` and keeps us clear of init().
Functions ¶
func AppendEscaped ¶ added in v0.26.15
AppendEscaped appends the body of the JSON string literal of s — what AppendString writes between its quotes — so a caller can join several pieces into one literal.
func AppendString ¶ added in v0.26.15
AppendString appends s to dst as a JSON string literal, quotes included. See the package comment for the escapes: invalid UTF-8 becomes U+FFFD, U+2028 and U+2029 are escaped, and '<', '>' and '&' are not.
func AppendUint ¶ added in v0.26.15
AppendUint appends v to dst in decimal, as a JSON number. A value past 2^53 is exact here and is not in a JavaScript reader.
Types ¶
type Object ¶ added in v0.26.15
Object is a JSON object being written by BeginObject: members land in the order they are named, and nothing allocates but the caller's slice.
func BeginObject ¶ added in v0.26.15
BeginObject appends the opening brace of an object to dst and returns the Object that writes its members after it, in the order they are named.