{"modulePath":"github.com/oapi-codegen/runtime","version":"v1.9.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package jsoncodec\n\nPackage jsoncodec holds the process-wide JSON codec that the runtime package and runtime/types share.\n\nIt 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.\n\n## Functions\n\n```go\nfunc Marshal(v any) ([]byte, error)\n```\nMarshal encodes v with the codec.\n\n```go\nfunc MarshalWrite(w io.Writer, v any) error\n```\nMarshalWrite encodes v to w: with the codec's MarshalWrite when it implements Streaming, otherwise with Marshal followed by a single Write.\n\n```go\nfunc Set(c Codec)\n```\nSet 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.\n\n```go\nfunc Unmarshal(data []byte, v any) error\n```\nUnmarshal decodes data into v with the codec.\n\n```go\nfunc UnmarshalRead(r io.Reader, v any) error\n```\nUnmarshalRead 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.\n\n## Types\n\n```go\ntype Codec interface {\n\tMarshal(v any) ([]byte, error)\n\tUnmarshal(data []byte, v any) error\n}\n```\nCodec encodes and decodes JSON. runtime.JSONCodec is an alias of it.\n\n```go\ntype Std struct{}\n```\nStd is encoding/json's json.Marshal and json.Unmarshal. runtime.StdJSONCodec is an alias of it.\n\nIt 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.\n\n```go\nfunc (Std) Marshal(v any) ([]byte, error)\n```\n\n```go\nfunc (Std) Unmarshal(data []byte, v any) error\n```\n\n```go\ntype Streaming interface {\n\tMarshalWrite(w io.Writer, v any) error\n\tUnmarshalRead(r io.Reader, v any) error\n}\n```\nStreaming is optionally implemented by a Codec that encodes to and decodes from a stream. runtime.StreamingJSONCodec is an alias of it.\n\n","path":"github.com/oapi-codegen/runtime/internal/jsoncodec","name":"jsoncodec","synopsis":"Package jsoncodec holds the process-wide JSON codec that the runtime package and runtime/types share.","isRedistributable":true}
