func (n *Node) OpenJSON(filename string) error {
	fp, err := os.Open(filename)
	defer fp.Close()
	if err != nil {
		log.Println(err)
		return err
	}
	return n.ReadJSON(bufio.NewReader(fp))
}
OpenJSON opens file over this tree from a JSON-encoded file -- see
ReadJSON for details, and OpenNewJSON for opening an entirely new tree.
package ki
import (
	"bufio"
	"bytes"
	"encoding/json"
	"encoding/xml"
	"errors"
	"fmt"
	"io"
	"io/ioutil"
	"log"
	"os"
	"reflect"
	"strconv"
	"strings"
	"github.com/goki/ki/kit"
)
var JSONTypePrefix = []byte("{\"ki.RootType\": ")
var JSONTypeSuffix = []byte("}\n")
func (n *Node) WriteJSON(writer io.Writer, indent bool) error {
	err := ThisCheck(n)
	if err != nil {
		return err
	}
	UniquifyNamesAll(n.This())
	var b []byte
	if indent {
		b, err = json.MarshalIndent(n.This(), "", "  ")
	} else {
		b, err = json.Marshal(n.This())
	}
	if err != nil {
		log.Println(err)
		return err
	}
	knm := kit.Types.TypeName(Type(n.This()))
	tstr := string(JSONTypePrefix) + fmt.Sprintf("\"%v\"}\n", knm)
	nwb := make([]byte, len(b)+len(tstr))
	copy(nwb, []byte(tstr))
	copy(nwb[len(tstr):], b)  
	_, err = writer.Write(nwb)
	if err != nil {
		log.Println(err)
	}
	return err
}
func (n *Node) SaveJSON(filename string) error {
	fp, err := os.Create(filename)
	defer fp.Close()
	if err != nil {
		log.Println(err)
		return err
	}
	bw := bufio.NewWriter(fp)
	err = n.WriteJSON(bw, Indent)  
	if err != nil {
		log.Println(err)
		return err
	}
	err = bw.Flush()
	if err != nil {
		log.Println(err)
	}
	return err
}
func (n *Node) ReadJSON(reader io.Reader) error {
	err := ThisCheck(n)
	if err != nil {
		log.Println(err)
		return err
	}
	b, err := ioutil.ReadAll(reader)
	if err != nil {
		log.Println(err)
		return err
	}
	updt := n.UpdateStart()
	stidx := 0
	if bytes.HasPrefix(b, JSONTypePrefix) {  
		stidx = bytes.Index(b, JSONTypeSuffix) + len(JSONTypeSuffix)
	}
	err = json.Unmarshal(b[stidx:], n.This())  
	UnmarshalPost(n.This())
	n.SetChildAdded()  
	n.UpdateEnd(updt)
	return err
}