summaryrefslogtreecommitdiff
path: root/json/node.go
diff options
context:
space:
mode:
authorFelix Hanley <felix@userspace.com.au>2018-11-18 23:23:16 +0000
committerFelix Hanley <felix@userspace.com.au>2018-11-18 23:23:16 +0000
commitbbf5d9bb88ee4fe955d810e90aa90c302e1dc02d (patch)
treed46ff62cbda52cfc5d82a54b17caa9906a3be3bc /json/node.go
parent44da796e192961b614e3540c4c1ec52f4bc0a290 (diff)
downloadquery-bbf5d9bb88ee4fe955d810e90aa90c302e1dc02d.tar.gz
query-bbf5d9bb88ee4fe955d810e90aa90c302e1dc02d.tar.bz2
Implement Stringifier for jsonnode
Diffstat (limited to 'json/node.go')
-rw-r--r--json/node.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/json/node.go b/json/node.go
index eb544dc..fd61ed1 100644
--- a/json/node.go
+++ b/json/node.go
@@ -3,6 +3,7 @@ package json
import (
"bytes"
"encoding/json"
+ "fmt"
"io"
"sort"
"strconv"
@@ -38,6 +39,10 @@ type Node struct {
level int
}
+func (n Node) String() string {
+ return fmt.Sprintf("[%s] %s(%s)", NodeNames[n.Type], n.DataType, n.Data)
+}
+
// ChildNodes gets all child nodes of the node.
func (n *Node) ChildNodes() []*Node {
var a []*Node