json

package
v0.0.0-...-2552c51 Latest Latest
Warning

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

Go to latest
Published: May 29, 2023 License: MIT Imports: 10 Imported by: 11

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) Bytes

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

func (Map) BytesWithError

func (s Map) BytesWithError(key string, defaultVal []byte) ([]byte, error)

func (Map) Copy

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

Copy returns copied map (todo dipcopy)

func (Map) EachMap

func (s Map) EachMap(key string, each func(int, Map) bool)

func (Map) EachSlice

func (s Map) EachSlice(key string, each func(int, any) bool)

func (Map) Float32

func (s Map) Float32(key string, defaultVal float32) float32

func (Map) Float64

func (s Map) Float64(key string, defaultVal float64) float64

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) IsBoolean

func (s Map) IsBoolean(key string) bool

func (Map) IsEmpty

func (s Map) IsEmpty() bool

func (Map) IsInt

func (s Map) IsInt(key string) bool

func (Map) JSON

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

JSON returns JSON source of the self object

func (Map) JSONIndent

func (s Map) JSONIndent(prefix, indent string) (res []byte)

JSONIndent returns JSON source of the self object with indent

func (Map) JSONPrettyString

func (s Map) JSONPrettyString() (res string)

func (Map) JSONString

func (s Map) JSONString() (res string)

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) LogPretty

func (s Map) LogPretty()

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) StringVal

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

func (Map) StringWithError

func (s Map) StringWithError(key, defaultVal string) (string, error)

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