xcodec

package
v0.0.0-...-9f39f39 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

README

编、解码器

用法

xcodec.Decode("json",[]byte(`{"a":1}`), &struct{A int}{})
xcodec.Encode("json", &struct{A int}{A:1})

Documentation

Index

Constants

View Source
const XcodecJson = "json"
View Source
const XcodecYaml = "yaml"

Variables

View Source
var (
	NoFindXCoderERR = errors.New("没有找到对应得编解码器")
)

Functions

func Decode

func Decode(typ string, data []byte, i interface{}) error

func Encode

func Encode(typ string, i interface{}) ([]byte, error)

func Register

func Register(name string, creator Xcodec)

Types

type Json

type Json struct{}

func (Json) Decode

func (Json) Decode(data []byte, i interface{}) error

func (Json) Encode

func (Json) Encode(i interface{}) ([]byte, error)

type Xcodec

type Xcodec interface {
	Decode(data []byte, i interface{}) error
	Encode(i interface{}) ([]byte, error)
}

type Yaml

type Yaml struct{}

func (Yaml) Decode

func (Yaml) Decode(data []byte, i interface{}) error

func (Yaml) Encode

func (Yaml) Encode(i interface{}) ([]byte, error)

Jump to

Keyboard shortcuts

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