djson

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bind

func Bind(src []byte, t interface{}) error

Bind 绑定到指定对象

func BindFromMap

func BindFromMap(src map[string]interface{}, t interface{}) error

BindFromMap 从map绑定到指定对象

func BindFromString

func BindFromString(src string, t interface{}) error

BindFromString 从字符串绑定到指定对象

func BindWithValidate added in v0.9.0

func BindWithValidate(src []byte, t interface{}) error

BindWithValidate 绑定到指定对象,并校验结构体

func Dump

func Dump(t interface{}) []byte

func DumpMap

func DumpMap(t interface{}) map[string]interface{}

func DumpMapWithoutKeys

func DumpMapWithoutKeys(t interface{}, without ...string) map[string]interface{}

func DumpString

func DumpString(t interface{}) string

func FormatDumpString

func FormatDumpString(t interface{}) string

func MustBind

func MustBind(src []byte, t interface{})

func MustBindFromString

func MustBindFromString(src string, t interface{})

func MustParse added in v0.9.2

func MustParse[T any](src []byte) T

MustParse 解析到指定类型

func MustParsePtr added in v0.9.2

func MustParsePtr[T any](src []byte) *T

MustParsePtr 解析到指定类型的指针

func Parse added in v0.7.0

func Parse[T any](src []byte) (T, error)

Parse 解析到指定类型

func ParseFromString added in v0.7.0

func ParseFromString[T any](src string) (T, error)

ParseFromString 从字符串解析到指定类型

func ParsePtr added in v0.7.0

func ParsePtr[T any](src []byte) (*T, error)

ParsePtr 解析到指定类型的指针

func ParsePtrFromString added in v0.7.0

func ParsePtrFromString[T any](src string) (*T, error)

ParsePtrFromString 从字符串解析到指定类型的指针

func ParsePtrWithValidate added in v0.9.0

func ParsePtrWithValidate[T any](src []byte) (*T, error)

ParsePtrWithValidate 解析到指定类型,并校验结构体

Types

type Encoder

type Encoder struct {
}

func NewEncoder

func NewEncoder() *Encoder

func (Encoder) Decode

func (e Encoder) Decode(d []byte, value interface{}) error

func (Encoder) DecodeString

func (e Encoder) DecodeString(d string, value interface{}) error

func (Encoder) Encode

func (e Encoder) Encode(value interface{}) []byte

func (Encoder) EncodeString

func (e Encoder) EncodeString(value interface{}) string

type JsonString

type JsonString json.RawMessage

func (JsonString) MarshalJSON

func (t JsonString) MarshalJSON() ([]byte, error)

MarshalJSON returns m as the JSON encoding of m.

func (*JsonString) Scan

func (t *JsonString) Scan(value interface{}) error

func (*JsonString) UnmarshalJSON

func (t *JsonString) UnmarshalJSON(data []byte) error

UnmarshalJSON sets *m to a copy of data.

func (JsonString) Value

func (t JsonString) Value() (driver.Value, error)

type Raw

type Raw = json.RawMessage

Jump to

Keyboard shortcuts

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