Documentation
¶
Overview ¶
Package jsonenc encodes values as encoding/json does, byte for byte, except that a nil slice is written as [] instead of null: Tern sends [] for pages, typed endpoints and live components, so their TypeScript types are T[] rather than T[] | null.
It's faster than encoding/json followed by a copy that fills in nil slices: each type's encoder is built once, and nothing is copied. Values that encode themselves (json.Marshaler, encoding.TextMarshaler) and the rare struct tag options it doesn't implement go through encoding/json.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Verbatim ¶
type Verbatim []byte
Verbatim is JSON this package wrote, written again as it is: no checking, compacting or escaping. Only for its own output, which is already compact and safe to inline in HTML.
func (Verbatim) MarshalJSON ¶
MarshalJSON is for encoding/json, which checks and compacts it.
func (*Verbatim) UnmarshalJSON ¶
UnmarshalJSON keeps the raw JSON, as json.RawMessage does.