Documentation
¶
Overview ¶
Package jsonkit is how anfra reads and writes JSON: encoding/json/v2 with one set of options, used by every package, so a value is encoded the same way whichever door it leaves by. Don't import encoding/json or encoding/json/v2 elsewhere; depguard refuses it. See docs/designs/json.md.
Index ¶
- func Marshal(v any) ([]byte, error)
- func MarshalEncode(enc *jsontext.Encoder, v any) error
- func MarshalIndent(v any) ([]byte, error)
- func MarshalWrite(w io.Writer, v any) error
- func Unmarshal(b []byte, v any) error
- func UnmarshalRead(r io.Reader, v any) error
- func UnmarshalReadStrict(r io.Reader, v any) error
- func Valid(b []byte) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalEncode ¶
MarshalEncode writes v to enc, with enc's options: for a MarshalJSONTo method, so the options of whatever is encoding it reach inside.
func MarshalIndent ¶
MarshalIndent is v as JSON, indented by two spaces, for a file people read.
func UnmarshalRead ¶
UnmarshalRead reads the one JSON value in r, to its end, into v.
func UnmarshalReadStrict ¶ added in v0.9.0
UnmarshalReadStrict is UnmarshalRead that also refuses a member v has no field for: for a request a server reads as its whole contract, where an unknown member is the caller's mistake, not something to ignore. A server that validates against a schema (apikit) refuses them there already.
Types ¶
This section is empty.