diff options
author | NeonXP <i@neonxp.dev> | 2022-11-21 04:31:56 +0300 |
---|---|---|
committer | NeonXP <i@neonxp.dev> | 2022-11-21 04:31:56 +0300 |
commit | 4054a50ce4232ebfc4dae043863ad96d46b25b43 (patch) | |
tree | 4ee57f8b0b5f66b142bb3898ba6e8162cb1b2a01 /json.go | |
parent | 4934a51c69e1975dc808e094e113b187ebb2c328 (diff) |
Better interfacev0.0.3
Diffstat (limited to 'json.go')
-rw-r--r-- | json.go | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -8,29 +8,29 @@ import ( ) // Marshal Node tree to []byte -func Marshal(node *model.Node) ([]byte, error) { +func Marshal(node model.Node) ([]byte, error) { return node.MarshalJSON() } // Unmarshal data to Node tree -func Unmarshal(data []byte) (*model.Node, error) { +func Unmarshal(data []byte) (model.Node, error) { return parser.Parse(string(data)) } // Query returns node by query string (dot notation) -func Query(json string, query string) (*model.Node, error) { +func Query(json string, query string) (model.Node, error) { n, err := parser.Parse(json) if err != nil { return nil, err } - return n.Query(strings.Split(query, ".")) + return model.Query(n, strings.Split(query, ".")) } // QueryArray returns node by array query -func QueryArray(json string, query []string) (*model.Node, error) { +func QueryArray(json string, query []string) (model.Node, error) { n, err := parser.Parse(json) if err != nil { return nil, err } - return n.Query(query) + return model.Query(n, query) } |