json

package
v0.0.0-...-6d6629b Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2022 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(r io.Reader, obj interface{}) error

func DecodeBytes

func DecodeBytes(src []byte, obj interface{}) error

func Log

func Log(v interface{})

func Marshal

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

func MarshalIndent

func MarshalIndent(v interface{}, prefix, indent string) ([]byte, error)

func Unmarshal

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

func UnmarshalFile

func UnmarshalFile(fileName string, v interface{}) (err error)

func UnmarshalReader

func UnmarshalReader(r io.Reader, v interface{}) error

Types

type JSONDecoder

type JSONDecoder struct {
	*json.Decoder
	// contains filtered or unexported fields
}

func InitJSONDecoder

func InitJSONDecoder(r io.Reader) *JSONDecoder

func InitJSONDecoderFromSource

func InitJSONDecoderFromSource(src []byte) *JSONDecoder

func (*JSONDecoder) Current

func (s *JSONDecoder) Current() JSONTokenType

func (*JSONDecoder) Decode

func (s *JSONDecoder) Decode(v interface{}) (err error)

func (*JSONDecoder) DecodeRaw

func (s *JSONDecoder) DecodeRaw(v interface{}) error

func (*JSONDecoder) EmbeddedLevel

func (s *JSONDecoder) EmbeddedLevel() int

func (*JSONDecoder) IsObjectClosed

func (s *JSONDecoder) IsObjectClosed() bool

func (*JSONDecoder) IsObjectKey

func (s *JSONDecoder) IsObjectKey() bool

func (*JSONDecoder) JSONTypeCheck

func (s *JSONDecoder) JSONTypeCheck(rv *reflect.Value) (t Type)

func (*JSONDecoder) Next

func (s *JSONDecoder) Next() error

func (*JSONDecoder) Token

func (s *JSONDecoder) Token() (t json.Token, err error)

type JSONFinisher

type JSONFinisher interface {
	JSONFinish(storeTemp Map) error
}

type JSONInterface

type JSONInterface interface {
	JSONDecode(*JSONDecoder) (isNil bool, err error)
}

type JSONObject

type JSONObject interface {
	JSONField(fieldName string, storeTemp Map) (fieldPtr interface{}, err error)
}

type JSONTokenType

type JSONTokenType byte
const (
	JSON_INVALID JSONTokenType = iota
	JSON_ARRAY
	JSON_OBJECT
	JSON_VALUE
)

func (JSONTokenType) String

func (s JSONTokenType) String() string

type Map

type Map map[string]interface{}

Map type

func FromMap

func FromMap(m map[string]interface{}) Map

FromMap convert map[string]interface{} to Map object

func MapFromInterface

func MapFromInterface(iface interface{}) (res Map)

FromInterface convert map[string]interface{} or Map interface to Map

func NewMap

func NewMap() Map

New init Map object

func (Map) Bool

func (s Map) Bool(key string, defaultVal bool) bool

Bool returns bool value by key

func (Map) Copy

func (s Map) Copy() (res Map)

Copy returns copied map (todo dipcopy)

func (Map) Int

func (s Map) Int(key string, defaultVal int64) int64

Int returns int64 value by key. If key isn't defined will be returned defaultVal arg value

func (Map) Int32

func (s Map) Int32(key string, defaultVal int) int

func (Map) IsEmpty

func (s Map) IsEmpty() bool

func (Map) JSON

func (s Map) JSON() (res []byte)

JSON Return JSON source of the self object

func (Map) KeyExists

func (s Map) KeyExists(key string) bool

KeyExists check value exists by key

func (Map) KeysExists

func (s Map) KeysExists(keys []string) string

KeysExists check values exists by keys list. Returns the first blank key found. If all keys are defined, an empty string will be returned

func (Map) Map

func (s Map) Map(key string, defaultVal Map) (res Map)

Map returns Map object by key If key isn't defined or have other type will be returned defaultVal arg value

func (Map) Slice

func (s Map) Slice(key string, defaultVal []interface{}) (res []interface{})

Slce returns slice of interface{} by key If key isn't defined or have a different type will be returned defaultVal arg value

func (Map) StorePtr

func (s Map) StorePtr(key string, val interface{}) interface{}

func (Map) String

func (s Map) String(key, defaultVal string) string

String returns string value by key If key isn't defined will be returned defaultVal arg value

func (Map) StringSlice

func (s Map) StringSlice(key string, defaultVal []string) (res []string)

StringSlice returns string slice by key If key isn't defined will be returned defaultVal arg value

func (Map) ToMap

func (s Map) ToMap() map[string]interface{}

ToMap returns map[string]interface{} of the self object

func (Map) Update

func (s Map) Update(m Map)

func (Map) Value

func (s Map) Value(key string, defaultVal interface{}) interface{}

Value returns interface object with attempt to convert to defaultVal type. If key isn't defined will be returned defaultVal arg value

func (Map) ValueJSON

func (s Map) ValueJSON(key string, defaultVal []byte) (res []byte)

ValueJSON returns json source object by key If key isn't defined will be returned defaultVal arg value

func (Map) Variable

func (s Map) Variable(key string, ptr interface{}) bool

type Type

type Type byte
const (
	TypeUndefined Type = iota
	TypeInterface
	TypeObject
	TypeSlice
)

Jump to

Keyboard shortcuts

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