json

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 27, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

func Marshal(v any) ([]byte, error)

func Name

func Name() string

func ReplaceDefaultCodec

func ReplaceDefaultCodec(codec Codec)

func Unmarshal

func Unmarshal(data []byte, v any) error

Types

type Codec

type Codec struct {
	// contains filtered or unexported fields
}

Codec is a Codec implementation with json.

func New

func New(opts ...Option) Codec

New returns a new Codec, default disableProtoJSON is false

func (Codec) Marshal

func (c Codec) Marshal(v any) ([]byte, error)

func (Codec) Name

func (Codec) Name() string

func (Codec) Unmarshal

func (c Codec) Unmarshal(data []byte, v any) error

type Option

type Option func(*Codec)

func WithDisableProtoJSON

func WithDisableProtoJSON() Option

WithDisableProtoJSON disable proto json codec.

func WithMarshalOptions

func WithMarshalOptions(marshalOpts protojson.MarshalOptions) Option

WithMarshalOptions is a configurable JSON format marshaler for proto.

func WithUnmarshalOptions

func WithUnmarshalOptions(unmarshalOpts protojson.UnmarshalOptions) Option

WithUnmarshalOptions is a configurable JSON format parser for proto.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL