Skip to content

add new json item not sync in memory #114

@perrynzhou

Description

@perrynzhou
  • plateform
mac os
  • code
func main() {
	b,_ := ioutil.ReadFile("./test_cluster.conf")
	jsoner,_ := gabs.ParseJSON(b)
	key :="cluster/test/demo"
	tmpMap := map[string]string{"aaa":"bbb"}
	keys_args  := strings.Split(key,"/")
	jsoner.Set(tmpMap,keys_args...)
	// if add that: jsoner,_ = gabs.ParseJSON(jsoner.Bytes()),i can search data
	ioutil.WriteFile("./temp.json",jsoner.BytesIndent(" "," "),os.ModePerm)
	c :=jsoner.Search(keys_args...)
	if c== nil {
		log.Println("c is nil")
	}else {
                //c.ChildrenMap is empty
		log.Println("c is not nil:",c.ChildrenMap())
		for k,v :=range c.ChildrenMap() {
			log.Printf("%v=%v",k,v)
		}
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions