ezjson

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OmitEmpty  = "omitempty"
	RustOption = "rust_option"
	OptSeen    = "opt_seen"
)

Variables

This section is empty.

Functions

func AllElem

func AllElem(in interface{}) reflect.Value

func IsPtr

func IsPtr(in interface{}) bool

func IsUnsafePointer

func IsUnsafePointer(in interface{}) bool

func Log

func Log(msg string) int

func Marshal

func Marshal(in interface{}) ([]byte, error)

func SetDisplay

func SetDisplay(f func([]byte) int)

func TypeOf

func TypeOf(in interface{}) reflect.Type

func Unmarshal

func Unmarshal(jsonstr []byte, out interface{}) error

func ValueOf

func ValueOf(in interface{}) reflect.Value

Types

type BaseName

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

func (*BaseName) Attribute

func (b *BaseName) Attribute(key string, value bool)

func (BaseName) GetJsonName

func (b BaseName) GetJsonName() string

func (BaseName) IsOmitEmpty

func (b BaseName) IsOmitEmpty() bool

func (BaseName) IsOptSeen

func (b BaseName) IsOptSeen() bool

func (BaseName) IsRustOption

func (b BaseName) IsRustOption() bool

func (BaseName) Name

func (b BaseName) Name() string

func (BaseName) Tag

func (b BaseName) Tag() string

type BaseOpt

type BaseOpt interface {
	//checking is value empty
	IsEmpty() bool

	//get encoded result
	Encode(isBrace bool) string

	//getting Value name
	Name() string

	//getting value
	Value() interface{}

	//getting type
	Type() reflect.Kind

	//getting tag
	Tag() string

	//setting values
	Set(value interface{}) error

	//setting attribute
	Attribute(key string, value bool)

	// whether we need to make a seen field on the struct
	// currently only for EmptyStruct, may extend this later
	IsOptSeen() bool
}

func Generate

func Generate(name, tag string, in interface{}, isDecoding bool) BaseOpt

interface

type BoolOpt

type BoolOpt struct {
	BaseName
	// contains filtered or unexported fields
}

func (BoolOpt) Encode

func (b BoolOpt) Encode(isBrace bool) string

func (BoolOpt) IsEmpty

func (b BoolOpt) IsEmpty() bool

func (*BoolOpt) Set

func (b *BoolOpt) Set(value interface{}) error

func (BoolOpt) Type

func (b BoolOpt) Type() reflect.Kind

func (BoolOpt) Value

func (b BoolOpt) Value() interface{}

type EmptyStruct

type EmptyStruct struct {
	Seen bool `json:"do_not_set_this_field,omitempty"`
}

Set this as EmptyStruct{Seen: true} so it will serialize, otherwise it is missing

func (EmptyStruct) WasSet

func (e EmptyStruct) WasSet() bool

type IntOpt

type IntOpt struct {
	BaseName
	// contains filtered or unexported fields
}

/int int16 int32 int64 support

func (IntOpt) Encode

func (i IntOpt) Encode(isBrace bool) string

func (IntOpt) IsEmpty

func (i IntOpt) IsEmpty() bool

func (*IntOpt) Set

func (i *IntOpt) Set(value interface{}) error

func (IntOpt) Type

func (i IntOpt) Type() reflect.Kind

func (IntOpt) Value

func (i IntOpt) Value() interface{}

type MapOpt

type MapOpt struct {
}

map support

type SliceOpt

type SliceOpt struct {
	BaseName
	// contains filtered or unexported fields
}

slice support

func (SliceOpt) Encode

func (s SliceOpt) Encode(isBrace bool) string

func (SliceOpt) IsEmpty

func (s SliceOpt) IsEmpty() bool

func (*SliceOpt) Set

func (s *SliceOpt) Set(value interface{}) error

func (SliceOpt) Type

func (s SliceOpt) Type() reflect.Kind

func (SliceOpt) Value

func (s SliceOpt) Value() interface{}

type StringOpt

type StringOpt struct {
	BaseName
	// contains filtered or unexported fields
}

/string support

func (StringOpt) Encode

func (s StringOpt) Encode(isBrace bool) string

func (StringOpt) IsEmpty

func (s StringOpt) IsEmpty() bool

func (*StringOpt) Set

func (s *StringOpt) Set(value interface{}) error

func (StringOpt) Type

func (s StringOpt) Type() reflect.Kind

func (StringOpt) Value

func (s StringOpt) Value() interface{}

type StructOpt

type StructOpt struct {
	BaseName
	// contains filtered or unexported fields
}

struct support

func (StructOpt) Encode

func (s StructOpt) Encode(isBrace bool) string

func (StructOpt) IsEmpty

func (s StructOpt) IsEmpty() bool

func (*StructOpt) Set

func (s *StructOpt) Set(value interface{}) error

func (StructOpt) Type

func (s StructOpt) Type() reflect.Kind

func (StructOpt) Value

func (s StructOpt) Value() interface{}

type UintOpt

type UintOpt struct {
	BaseName
	// contains filtered or unexported fields
}

/int uint16 uint32 uint64 uintptr support

func (UintOpt) Encode

func (u UintOpt) Encode(isBrace bool) string

func (UintOpt) IsEmpty

func (u UintOpt) IsEmpty() bool

func (*UintOpt) Set

func (u *UintOpt) Set(value interface{}) error

func (UintOpt) Type

func (u UintOpt) Type() reflect.Kind

func (UintOpt) Value

func (u UintOpt) Value() interface{}

Jump to

Keyboard shortcuts

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