func (t *Tree) SetMapping(config string) error {
	var err error
	var conf map[string][]map[string]interface{}
	if err = json.Unmarshal([]byte(config), &conf); err == nil {
		t.Reset(true)
		if branches, ok := conf["branches"]; ok {
			for _, b := range branches {
				t.AddBranch(b["branch"].(string), b["rpc"].(string), b["fingerprint"].(string))
			}
		}
		if mounts, ok := conf["tree"]; ok {
			for _, m := range mounts {
				t.AddMapping(m["path"].(string), m["branch"].(string), m["writeable"].(bool))
			}
		}
	}
	return err
}
/*
SetMapping adds a given tree mapping configuration in a JSON string.
package rufs
import (
	"bytes"
	"crypto/tls"
	"encoding/gob"
	"encoding/json"
	"fmt"
	"io"
	"os"
	"path"
	"regexp"
	"sort"
	"strings"
	"sync"
	"time"
	"unicode/utf8"
	"devt.de/krotik/common/bitutil"
	"devt.de/krotik/common/fileutil"
	"devt.de/krotik/common/stringutil"
	"devt.de/krotik/rufs/config"
	"devt.de/krotik/rufs/node"
)
type Tree struct {
	client      *node.Client              
	treeLock    *sync.RWMutex             
	root        *treeItem                 
	branches    []map[string]string       
	branchesAll []map[string]string       
	mapping     []map[string]interface{}  
	mappingAll  []map[string]interface{}  
}
func NewTree(cfg map[string]interface{}, cert *tls.Certificate) (*Tree, error) {
	var err error
	var t *Tree
	if err = config.CheckTreeConfig(cfg); err == nil {
		c := node.NewClient(fileutil.ConfStr(cfg, config.TreeSecret), cert)
		t = &Tree{c, &sync.RWMutex{}, &treeItem{make(map[string]*treeItem),
			[]string{}, []bool{}}, []map[string]string{},
			[]map[string]string{}, []map[string]interface{}{},
			[]map[string]interface{}{}}
	}
	return t, err
}
func (t *Tree) Config() string {
	t.treeLock.RLock()
	defer t.treeLock.RUnlock()
	out, _ := json.MarshalIndent(map[string]interface{}{
		"branches": t.branches,
		"tree":     t.mapping,
	}, "", "  ")
	return string(out)
}