array

package
v1.0.2007 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Overview

Example
Get(arrData, "b.hhTy3.666.3")

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	ErrOutOfBounds = errors.New("out of bounds")
)

Functions

func Exists added in v1.0.1002

func Exists(source any, key string) bool

判断是否存在 if key in source return true or false

func Find added in v1.0.1002

func Find(source any, key string) any

查找数据 find data with key from source

func Get added in v1.0.1002

func Get(source any, key string, defVal ...any) any

获取数据 get data with key from source and can set default value

func JSONPointerToSlice added in v1.0.2003

func JSONPointerToSlice(path string) ([]string, error)

format JSONPointer to Slice

func KeyDelimPathToSlice added in v1.0.2003

func KeyDelimPathToSlice(path, keyDelim string) []string

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

func JSONPointer(source any, path string) (*Array, error)

获取数据 get data and return Array

func New

func New(source any) *Array

New Array

func ParseJSON added in v1.0.2001

func ParseJSON(source []byte) (*Array, error)

解析 JSON 数据 parse json data

func ParseJSONDecoder added in v1.0.2003

func ParseJSONDecoder(decoder *json.Decoder) (*Array, error)

ParseJSONDecoder applies a json.Decoder to a *Container.

func Search(source any, path ...string) *Array

搜索数据 Search data with key from source

func Sub added in v1.0.2003

func Sub(source any, key string) *Array

获取数据 get data and return Array

func (*Array) ArrayOfSize added in v1.0.2003

func (this *Array) ArrayOfSize(size int, path ...any) (*Array, error)

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

func (this *Array) ArrayOfSizeIndex(size, index int) (*Array, error)

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

func (this *Array) ArrayOfSizeKey(size int, key string) (*Array, error)

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

func (this *Array) Children() []*Array

返回 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

func (this *Array) ChildrenMap() map[string]*Array

返回 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) Delete added in v1.0.2003

func (this *Array) Delete(path ...any) error

使用路径删除数据 delete data with path

func (*Array) DeleteKey added in v1.0.2003

func (this *Array) DeleteKey(key string) error

使用 key 删除数据 delete data with key

func (*Array) Exists added in v1.0.2001

func (this *Array) Exists(key string) bool

判断是否存在 if key in source return true or false

func (*Array) Find added in v1.0.2001

func (this *Array) Find(key string) any

查找数据 find data with key

func (*Array) Flatten added in v1.0.2003

func (this *Array) Flatten() (map[string]any, error)

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

func (this *Array) FlattenIncludeEmpty() (map[string]any, error)

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) Get added in v1.0.2001

func (this *Array) Get(key string, defVal ...any) any

获取数据 get data with key and can set default value

func (*Array) Index added in v1.0.2003

func (this *Array) Index(index int) *Array

使用 index 搜索数据 Index attempts to find and return an element

func (*Array) IsArray added in v1.0.2006

func (this *Array) IsArray() bool

判断是否是 slice or map 类型 if the source is slice or map and return true

func (*Array) IsMap added in v1.0.2006

func (this *Array) IsMap() bool

判断是否是 map 类型 if the source is map and return true

func (*Array) IsSlice added in v1.0.2006

func (this *Array) IsSlice() bool

判断是否是 slice 类型 if the source is slice and return true

func (*Array) JSONPointer added in v1.0.2003

func (this *Array) JSONPointer(path string) (*Array, error)

获取数据 get data and return Array

func (*Array) Len added in v1.0.2006

func (this *Array) Len() (num int)

获取 array, slice, map or string 的长度 get array, slice, map or string len

func (*Array) MarshalJSON added in v1.0.2005

func (this *Array) MarshalJSON() ([]byte, error)

返回 JSON 数据 return JSON data

func (*Array) Search added in v1.0.2001

func (this *Array) Search(path ...string) *Array

搜索数据 Search data with key

func (*Array) Set added in v1.0.2003

func (this *Array) Set(value any, path ...any) (*Array, error)

设置数据 set data with path

func (*Array) SetIndex added in v1.0.2003

func (this *Array) SetIndex(value any, index int) (*Array, error)

SetIndex attempts to set a value of an array element based on an index.

func (*Array) SetKey added in v1.0.2003

func (this *Array) SetKey(value any, key string) (*Array, error)

设置数据 set data with key

func (*Array) String added in v1.0.2003

func (this *Array) String() string

String marshals an element to a JSON formatted string.

func (*Array) Sub added in v1.0.2003

func (this *Array) Sub(key string) *Array

获取数据 get data and return Array

func (*Array) ToJSON added in v1.0.2003

func (this *Array) ToJSON() []byte

返回 JSON 数据 return JSON data

func (*Array) ToJSONIndent added in v1.0.2003

func (this *Array) ToJSONIndent(prefix, indent string) []byte

BytesIndent marshals an element to a JSON []byte blob formatted with a prefix and indent string.

func (*Array) Value added in v1.0.2003

func (this *Array) Value() any

返回数据 return the source data

func (*Array) WithKeyDelim added in v1.0.2001

func (this *Array) WithKeyDelim(data string) *Array

设置 keyDelim set keyDelim string

Jump to

Keyboard shortcuts

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