Documentation
¶
Overview ¶
Example ¶
Get(arrData, "b.hhTy3.666.3")
Index ¶
- Variables
- func Exists(source any, key string) bool
- func Find(source any, key string) any
- func Get(source any, key string, defVal ...any) any
- func JSONPointerToSlice(path string) ([]string, error)
- func KeyDelimPathToSlice(path, keyDelim string) []string
- type Array
- func (this *Array) ArrayOfSize(size int, path ...any) (*Array, error)
- func (this *Array) ArrayOfSizeIndex(size, index int) (*Array, error)
- func (this *Array) ArrayOfSizeKey(size int, key string) (*Array, error)
- func (this *Array) Children() []*Array
- func (this *Array) ChildrenMap() map[string]*Array
- func (this *Array) Delete(path ...any) error
- func (this *Array) DeleteKey(key string) error
- func (this *Array) Exists(key string) bool
- func (this *Array) Find(key string) any
- func (this *Array) Flatten() (map[string]any, error)
- func (this *Array) FlattenIncludeEmpty() (map[string]any, error)
- func (this *Array) Get(key string, defVal ...any) any
- func (this *Array) Index(index int) *Array
- func (this *Array) IsArray() bool
- func (this *Array) IsMap() bool
- func (this *Array) IsSlice() bool
- func (this *Array) JSONPointer(path string) (*Array, error)
- func (this *Array) Len() (num int)
- func (this *Array) MarshalJSON() ([]byte, error)
- func (this *Array) Search(path ...string) *Array
- func (this *Array) Set(value any, path ...any) (*Array, error)
- func (this *Array) SetIndex(value any, index int) (*Array, error)
- func (this *Array) SetKey(value any, key string) (*Array, error)
- func (this *Array) String() string
- func (this *Array) Sub(key string) *Array
- func (this *Array) ToJSON() []byte
- func (this *Array) ToJSONIndent(prefix, indent string) []byte
- func (this *Array) Value() any
- func (this *Array) WithKeyDelim(data string) *Array
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrOutOfBounds = errors.New("out of bounds")
)
Functions ¶
func JSONPointerToSlice ¶ added in v1.0.2003
format JSONPointer to Slice
func KeyDelimPathToSlice ¶ added in v1.0.2003
format Path with KeyDelim to Slice
Types ¶
type Array ¶ added in v1.0.2001
type Array struct {
// contains filtered or unexported fields
}
*
- 获取数组数据 / array struct *
- @create 2022-5-3
- @author deatil
func JSONPointer ¶ added in v1.0.2003
获取数据 get data and return Array
func ParseJSONDecoder ¶ added in v1.0.2003
ParseJSONDecoder applies a json.Decoder to a *Container.
func (*Array) ArrayOfSize ¶ added in v1.0.2003
ArrayOfSize creates a new array of a particular size at a path. Returns an error if the path contains a collision with a non object type.
func (*Array) ArrayOfSizeIndex ¶ added in v1.0.2003
ArrayOfSizeIndex creates a new array of a particular size at a index. Returns an error if the path contains a collision with a non object type.
func (*Array) ArrayOfSizeKey ¶ added in v1.0.2003
ArrayOfSizeIndex creates a new array of a particular size at a key. Returns an error if the path contains a collision with a non object type.
func (*Array) Children ¶ added in v1.0.2003
返回 slice 数据 Children returns a slice of all children of an array element. This also works for objects, however, the children returned for an source will be in a random order and you lose the names of the returned objects this way. If the underlying container value isn't an array or map nil is returned.
func (*Array) ChildrenMap ¶ added in v1.0.2003
返回 map 数据 ChildrenMap returns a map of all the children of an source element. IF the underlying value isn't a source then an empty map is returned.
func (*Array) Flatten ¶ added in v1.0.2003
Flatten a array or slice into an source of key/value pairs for each field, where the key is the full path of the structured field in dot path notation matching the spec for the method Path.
func (*Array) FlattenIncludeEmpty ¶ added in v1.0.2003
FlattenIncludeEmpty a array or slice into an source of key/value pairs for each field, just as Flatten, but includes empty arrays and objects, where the key is the full path of the structured field in dot path notation matching the spec for the method Path.
func (*Array) IsArray ¶ added in v1.0.2006
判断是否是 slice or map 类型 if the source is slice or map and return true
func (*Array) JSONPointer ¶ added in v1.0.2003
获取数据 get data and return Array
func (*Array) Len ¶ added in v1.0.2006
获取 array, slice, map or string 的长度 get array, slice, map or string len
func (*Array) MarshalJSON ¶ added in v1.0.2005
返回 JSON 数据 return JSON data
func (*Array) SetIndex ¶ added in v1.0.2003
SetIndex attempts to set a value of an array element based on an index.
func (*Array) ToJSONIndent ¶ added in v1.0.2003
BytesIndent marshals an element to a JSON []byte blob formatted with a prefix and indent string.
func (*Array) WithKeyDelim ¶ added in v1.0.2001
设置 keyDelim set keyDelim string