Documentation
¶
Overview ¶
Package jsoncodec holds the process-wide JSON codec that the runtime package and runtime/types share.
It is internal because runtime imports types, so types cannot import runtime. The runtime package re-exports its symbols, as aliases of the types and one-line wrappers of the functions, so that nothing is defined twice.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalWrite ¶
MarshalWrite encodes v to w: with the codec's MarshalWrite when it implements Streaming, otherwise with Marshal followed by a single Write.
func Set ¶
func Set(c Codec)
Set replaces the codec. nil restores the default, and so does Std itself: it is the default's byte half, and passing it is the natural way to say "encoding/json", not a request for the buffered stream path.
func UnmarshalRead ¶
UnmarshalRead decodes v from r: with the codec's UnmarshalRead when it implements Streaming, otherwise by reading r to its end and calling Unmarshal. When r is nil or holds no value, nothing or only JSON white space, it returns io.EOF without involving the codec, whose own report of an empty input varies.
Types ¶
type Std ¶
type Std struct{}
Std is encoding/json's json.Marshal and json.Unmarshal. runtime.StdJSONCodec is an alias of it.
It deliberately doesn't implement Streaming: a codec that embeds it and overrides Marshal or Unmarshal then encodes and decodes streams through its own methods, via MarshalWrite and UnmarshalRead's fall-through, rather than through encoding/json's Encoder and Decoder promoted from Std.