encoding

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 23, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotAPointer = errors.New("v argument must be a pointer")
)

Functions

func GetJSONObj added in v0.1.1

func GetJSONObj(str string, out interface{})

GetJSONObj string convert to obj

func GetJSONStr added in v0.1.1

func GetJSONStr(obj interface{}, isFormat bool) string

func GzipDecode

func GzipDecode(in []byte) ([]byte, error)

GzipDecode 解码

func GzipEncode

func GzipEncode(in []byte) ([]byte, error)

GzipEncode 编码

func JSONDecode added in v0.1.1

func JSONDecode(obj interface{}) string

JSONDecode Json Decode

func JSONEncode added in v0.1.1

func JSONEncode(str string, out interface{})

JSONEncode string convert to obj

func JSONPrettyDecode added in v0.1.1

func JSONPrettyDecode(obj interface{}) string

func Marshal

func Marshal(e Encoding, v interface{}) (data []byte, err error)

Marshal encode data

func MarshalToString

func MarshalToString(v interface{}) string

MarshalToString JSON编码为字符串

func Unmarshal

func Unmarshal(e Encoding, data []byte, v interface{}) (err error)

Types

type Encoding

type Encoding interface {
	Marshal(v interface{}) ([]byte, error)
	Unmarshal(data []byte, v interface{}) error
}

Encoding 编码接口定义

type GobEncoding

type GobEncoding struct{}

func (GobEncoding) Marshal

func (g GobEncoding) Marshal(v interface{}) ([]byte, error)

func (GobEncoding) Unmarshal

func (g GobEncoding) Unmarshal(data []byte, value interface{}) error

type JSONEncoding

type JSONEncoding struct{}

func (JSONEncoding) Marshal

func (j JSONEncoding) Marshal(v interface{}) ([]byte, error)

func (JSONEncoding) Unmarshal

func (j JSONEncoding) Unmarshal(data []byte, value interface{}) error

type JSONGzipEncoding

type JSONGzipEncoding struct{}

func (JSONGzipEncoding) Marshal

func (jz JSONGzipEncoding) Marshal(v interface{}) ([]byte, error)

func (JSONGzipEncoding) Unmarshal

func (jz JSONGzipEncoding) Unmarshal(data []byte, value interface{}) error

Unmarshal json encode and gzip

type JSONSnappyEncoding

type JSONSnappyEncoding struct{}

func (JSONSnappyEncoding) Marshal

func (s JSONSnappyEncoding) Marshal(v interface{}) (data []byte, err error)

Marshal 序列化

func (JSONSnappyEncoding) Unmarshal

func (s JSONSnappyEncoding) Unmarshal(data []byte, value interface{}) error

Unmarshal 反序列化

type MsgPackEncoding

type MsgPackEncoding struct{}

func (MsgPackEncoding) Marshal

func (mp MsgPackEncoding) Marshal(v interface{}) ([]byte, error)

func (MsgPackEncoding) Unmarshal

func (mp MsgPackEncoding) Unmarshal(data []byte, value interface{}) error

type PhpSerializeEncoding added in v0.0.4

type PhpSerializeEncoding struct{}

func (PhpSerializeEncoding) Marshal added in v0.0.4

func (p PhpSerializeEncoding) Marshal(v interface{}) ([]byte, error)

func (PhpSerializeEncoding) Unmarshal added in v0.0.4

func (p PhpSerializeEncoding) Unmarshal(data []byte, value interface{}) error

Jump to

Keyboard shortcuts

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