json

package
v0.12.3 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package json provides the json codec.

The code and tests in this package is derived from https://github.com/go-kratos/kratos under MIT license https://github.com/go-kratos/kratos/blob/main/LICENSE

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Codec

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

Codec is a Codec implementation with json.

func NewCodec

func NewCodec(opts ...Option) Codec

NewCodec creates a new json codec

func (Codec) Marshal

func (c Codec) Marshal(v interface{}) ([]byte, error)

Marshal serialize the interface{} to []byte

func (Codec) Unmarshal

func (c Codec) Unmarshal(data []byte, v interface{}) error

Unmarshal deserialize the []byte to interface{}

type Option

type Option func(*Codec)

Option is the type of functional options to codec

func WithIndent

func WithIndent(indent string) Option

WithIndent allows the codec to indent json output while marshalling. It is useful when the json output is meant for humans to read.

Jump to

Keyboard shortcuts

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