array

package
v1.0.2003 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 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 key data from source

func Get added in v1.0.1002

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

获取 get key data from source with default value

func JSONPointerToSlice added in v1.0.2003

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

func KeyDelimPathToSlice added in v1.0.2003

func KeyDelimPathToSlice(path, keyDelim string) []string

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

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

func (*Array) ArrayOfSizeKey added in v1.0.2003

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

func (*Array) Children added in v1.0.2003

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

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

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 key data from source

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 key data from source with default value

func (*Array) Index added in v1.0.2003

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

Index attempts to find and return an element

func (*Array) JSONPointer added in v1.0.2003

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

func (*Array) Search added in v1.0.2001

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

搜索 Search data with key from source

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 source data

func (*Array) WithKeyDelim added in v1.0.2001

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

设置 keyDelim with keyDelim

Jump to

Keyboard shortcuts

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