Open alanywlee opened 7 years ago
func main(){
str := "{\"words\":[{\"text\":\"123\"},{\"text\":\"456\"}]}"
node2 := new(j4g.JsonNode)
node2.Name = "newword"
node, err := j4g.LoadByString(str)
if err != nil {
fmt.Print("json4g.LoadByString()", str, "\n", err)
}else{
node2.SetValue(node.GetNodeByName("words"))
}
fmt.Println(node2.ToString())
}
I also made another try using above code, and found output nothing like this:
"newword":{}
Did I do anything wrong, or are there any other way to make node array work?
I want to compose a json object like above, However, using []JsonNode to SetValue([]JsonNode) seems not working. It didn't return error but always got nothing. Are there any standard way to make json node array work?