finder

package
v0.0.0-...-cdfbdfc Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ParentNodeType  = "parent"
	ChildNodeType   = "child"
	BrotherNodeType = "brother"
)

Variables

View Source
var (
	ErrKeyNotFound = errors.New("Not found the key")
)
View Source
var (
	ErrNotJSONObject = fmt.Errorf("Not JSON Object")
)

Functions

func FindKey

func FindKey(jsonStr string, key *Key) ([]string, error)

FindKey find value with key

Types

type Key

type Key struct {
	Fields      []string `json:"fields"`
	K           string   `json:"k"`
	V           string   `json:"v"`
	IsFind      bool     `json:"is_find"`
	ParentKeys  []*Key   `json:"parent_keys"`
	BrotherKeys []*Key   `json:"brother_keys"`

	Err error `json:"error"`
	// contains filtered or unexported fields
}

Key string

func BuildKey

func BuildKey(parentKeys []string, brotherKeys []string, valueKey string) (*Key, error)

BuildKey build key

func GetKey

func GetKey(results []gjson.Result, level int, key *Key) ([]*Key, error)

GetKey get value with key

func (*Key) E

func (k *Key) E(err error)

E build error

func (*Key) Find

func (k *Key) Find()

Find find

func (*Key) Len

func (k *Key) Len() int

Len len

func (*Key) Less

func (k *Key) Less(i, j int) bool

Less less

func (*Key) PrintPtr

func (k *Key) PrintPtr()

PrintPtr print ptr

func (*Key) String

func (k *Key) String() string

func (*Key) Swap

func (k *Key) Swap(i, j int)

Swap swap

func (*Key) Val

func (k *Key) Val(v string)

Val v

type KeyNode

type KeyNode struct {
	Name        string      `json:"name"`         // 键名
	IsRoot      bool        `json:"is_root"`      // 是否顶结点
	Level       int         `json:"level"`        // 层级
	Data        interface{} `json:"data"`         // 值
	ChildNode   *KeyNode    `json:"child_node"`   // 子结点
	BrotherNode *KeyNode    `json:"brother_node"` // 兄弟结点
}

KeyNode key node

func BuildKeyTree

func BuildKeyTree(keys []string) (*KeyNode, error)

BuildKeyTree build tree

func (*KeyNode) String

func (k *KeyNode) String() string

Jump to

Keyboard shortcuts

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