Documentation ¶
Index ¶
- type Branch
- type InvalidTypeError
- type MapPath
- func (this *MapPath) Array(refType reflect.Type, path string) (interface{}, bool, error)
- func (this *MapPath) Bool(path string, fallback ...bool) (bool, error)
- func (this *MapPath) BoolV(path string, fallback ...bool) bool
- func (this *MapPath) Child(path string, fallback ...*MapPath) (*MapPath, error)
- func (this *MapPath) ChildV(path string, fallback ...*MapPath) *MapPath
- func (this *MapPath) Childs(path string, fallback ...[]*MapPath) ([]*MapPath, error)
- func (this *MapPath) ChildsV(path string, fallback ...[]*MapPath) []*MapPath
- func (this *MapPath) Float(path string, fallback ...float64) (float64, error)
- func (this *MapPath) FloatV(path string, fallback ...float64) float64
- func (this *MapPath) Floats(path string, fallback ...[]float64) ([]float64, error)
- func (this *MapPath) FloatsV(path string, fallback ...[]float64) []float64
- func (this *MapPath) Get(path string, fallback ...interface{}) (interface{}, error)
- func (this *MapPath) GetAs(path string, typ reflect.Type, fallback ...interface{}) (interface{}, error)
- func (this *MapPath) Has(path string) bool
- func (this *MapPath) Int(path string, fallback ...int) (int, error)
- func (this *MapPath) IntV(path string, fallback ...int) int
- func (this *MapPath) Ints(path string, fallback ...[]int) ([]int, error)
- func (this *MapPath) IntsV(path string, fallback ...[]int) []int
- func (this *MapPath) Map(path string, fallback ...map[string]interface{}) (map[string]interface{}, error)
- func (this *MapPath) MapV(path string, fallback ...map[string]interface{}) map[string]interface{}
- func (this *MapPath) Maps(path string, fallback ...[]map[string]interface{}) ([]map[string]interface{}, error)
- func (this *MapPath) MapsV(path string, fallback ...[]map[string]interface{}) []map[string]interface{}
- func (this *MapPath) Root() map[string]interface{}
- func (this *MapPath) String(path string, fallback ...string) (string, error)
- func (this *MapPath) StringV(path string, fallback ...string) string
- func (this *MapPath) Strings(path string, fallback ...[]string) ([]string, error)
- func (this *MapPath) StringsV(path string, fallback ...[]string) []string
- type NotFoundError
- type UnsupportedTypeError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Branch ¶
type Branch map[string]interface{}
Branch is a shorthand for the map-string structures we're working with
type InvalidTypeError ¶
type InvalidTypeError struct {
// contains filtered or unexported fields
}
InvalidTypeError is returned if a type getter (eg GetInt) is used but the found type cannot be converted
func (*InvalidTypeError) Error ¶
func (err *InvalidTypeError) Error() string
type MapPath ¶
type MapPath struct {
// contains filtered or unexported fields
}
MapPath is the primary object type this package is about
func FromJsonFile ¶
FromJsonFile is a factory method to create a MapPath from a JSON file
func NewMapPath ¶
NewMapPath creates is the primary constructor
func (*MapPath) Array ¶
GetArray returns nested array of provided type. Fallback values are not supported. If the path value is not an array then an InvalidTypeError is returned. You should use the specialized methods (GetInts, GetStrings..) unless you know what you are doing.
func (*MapPath) Bool ¶
GetInt returns int value of path. If value cannot be parsed or converted then an InvalidTypeError is returned
func (*MapPath) BoolV ¶
GetBoolV returns bool value of path. If value cannot be parsed or converted then fallback or false is returned. Handy in single value context.
func (*MapPath) Child ¶
GetSub return a new MapPath object representing the sub structure, which needs to be a map. If the sub structure is of any other type then an InvalidTypeError is returned
func (*MapPath) ChildV ¶
GetMapV returns *MapPath value of path. If value cannot be parsed or converted then fallback or nil is returned. Handy in single value context.
func (*MapPath) Childs ¶
GetSubs returns a nested array of sub structures. If the path value is not an array of maps then an InvalidTypeError is returned.
func (*MapPath) ChildsV ¶
GetSubsV returns []*MapPath value of path. If value cannot be parsed or converted then fallback or nil is returned. Handy in single value context.
func (*MapPath) Float ¶
GetFloat returns float64 value of path. If value cannot be parsed or converted then an InvalidTypeError is returned
func (*MapPath) FloatV ¶
GetFloatV returns float64 value of path. If value cannot be parsed or converted then fallback or 0.0 is returned. Handy in single value context.
func (*MapPath) Floats ¶
GetFloats returns an array of float64 values. Tries to convert (eg int) or parse (string) values. If the path value cannot be parsed or converted than an InvalidTypeError is returned.
func (*MapPath) FloatsV ¶
GetFloatsV returns []float64 value of path. If value cannot be parsed or converted then fallback or nil is returned. Handy in single value context.
func (*MapPath) Int ¶
GetInt returns int value of path. If value cannot be parsed or converted then an InvalidTypeError is returned
func (*MapPath) IntV ¶
GetIntV returns int value of path. If value cannot be parsed or converted then fallback or 0 is returned. Handy in single value context.
func (*MapPath) Ints ¶
GetInts returns an array of int values. Tries to convert (eg float) or parse (string) values. If the path value cannot be parsed or converted than an InvalidTypeError is returned.
func (*MapPath) IntsV ¶
GetIntsV returns []int value of path. If value cannot be parsed or converted then fallback or nil is returned. Handy in single value context.
func (*MapPath) Map ¶
func (this *MapPath) Map(path string, fallback ...map[string]interface{}) (map[string]interface{}, error)
GetMap returns the map value of path. If value is not a map then an InvalidTypeError is returned
func (*MapPath) MapV ¶
GetMapV returns map[string]interface{} value of path. If value cannot be parsed or converted then fallback or nil is returned. Handy in single value context.
func (*MapPath) Maps ¶
func (this *MapPath) Maps(path string, fallback ...[]map[string]interface{}) ([]map[string]interface{}, error)
GetMaps returns a nested array of maps. If the path value is not an array of maps then an InvalidTypeError is returned.
func (*MapPath) MapsV ¶
func (this *MapPath) MapsV(path string, fallback ...[]map[string]interface{}) []map[string]interface{}
GetMapsV returns []map[string]interface{} value of path. If value cannot be parsed or converted then fallback or nil is returned. Handy in single value context.
func (*MapPath) String ¶
GetString returns string value of path. If value cannot be converted then an InvalidTypeError is returned
func (*MapPath) StringV ¶
GetStringV returns string value of path. If value cannot be parsed or converted then fallback or "" is returned. Handy in single value context.
type NotFoundError ¶
type NotFoundError string
NotFoundError is returned if a given path cannot be found
func (NotFoundError) Error ¶
func (err NotFoundError) Error() string
type UnsupportedTypeError ¶
type UnsupportedTypeError string
UnsupportedTypeError is returned if an unsupported type is used
func (UnsupportedTypeError) Error ¶
func (err UnsupportedTypeError) Error() string