diff options
author | NeonXP <i@neonxp.dev> | 2022-11-16 05:12:20 +0300 |
---|---|---|
committer | NeonXP <i@neonxp.dev> | 2022-11-16 05:12:20 +0300 |
commit | c730afe0f889587630789c4fa38267d1edf465f2 (patch) | |
tree | 4aa4d40bee3e78018d1d0a462595246701cd0090 /README | |
parent | a321bfe7b2f6db5078de7b2e5ed5ddcccd65f319 (diff) |
Fix md files
Diffstat (limited to 'README')
-rw-r--r-- | README | 65 |
1 files changed, 0 insertions, 65 deletions
@@ -1,65 +0,0 @@ -# JSON parsing library - -This library is an marshaler/unmarshaler for JSON in a tree of nodes. Also allows you to make queries over these trees. - -## Library interface - -```go -package json // import "go.neonxp.dev/json" - -// Marshal Node tree to []byte -func Marshal(node *model.Node) ([]byte, error) - -// Unmarshal data to Node tree -func Unmarshal(data []byte) (*model.Node, error) - -// Query returns node by query string (dot notation) -func Query(json string, query string) (*model.Node, error) - -// QueryArray returns node by array query -func QueryArray(json string, query []string) (*model.Node, error) -``` - -## Node methods - -```go -package model // import "go.neonxp.dev/json/model" - -// Node of JSON tree -type Node struct { - Type NodeType -} - -// NewNode creates new node from value -func NewNode(value any) *Node - -// Get node from object by key -func (n *Node) Get(key string) (*Node, error) - -// Index returns node by index from array -func (n *Node) Index(idx int) (*Node, error) - -// Set node to object by key -func (n *Node) Set(key string, value *Node) error - -// SetIndex sets node to array by index -func (n *Node) SetIndex(idx int, value *Node) error - -// SetValue to node -func (n *Node) SetValue(value any) - -// Map callback to each key value pair of object -func (n *Node) Map(cb func(key string, value *Node) (*Node, error)) error - -// Each applies callback to each element of array -func (n *Node) Each(cb func(idx int, value *Node) error) error - -// Query returns node by array query -func (n *Node) Query(query []string) (*Node, error) - -// Value returns value of node -func (n *Node) Value() any - -// MarshalJSON to []byte -func (n *Node) MarshalJSON() ([]byte, error) -``` |