From bbf5d9bb88ee4fe955d810e90aa90c302e1dc02d Mon Sep 17 00:00:00 2001 From: Felix Hanley Date: Mon, 19 Nov 2018 10:23:16 +1100 Subject: Implement Stringifier for jsonnode --- json/node.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'json/node.go') 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 -- cgit v1.2.3