-
-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Container.Set does not take effect on parent node if param "hierarchy" is empty #118
Comments
func test2() {
bs := []byte(`["james","raynor"]`)
data, _ := gabs.ParseJSON(bs)
ds := data.Children()
for i := range ds {
nv, _ := ds[i].Set("bond")
ds[i] = nv
}
fmt.Println(data.String())
// output : ["james","raynor"]
} It is troublesome to iterate arrays. |
Hey, thanks for trying Gabs! I think this relates to #91. For your first example, For your second example, try this: func test2() {
bs := []byte(`["james","raynor"]`)
data, _ := gabs.ParseJSON(bs)
ds := data.Children()
for i := range ds {
nv, _ := ds[i].Set("bond")
_, _ = data.SetIndex(nv.Data(), i)
}
fmt.Println(data.String())
// output : ["bond","bond"]
} Hope this helps. |
Thank you a lot for response! Your advice to the second example is helpful. For the first example, what confused to me is |
You're welcome! Yeah, I agree, there are some inconsistencies in the API as mentioned in the issue I linked to. Not sure if there are any plans to address them for the time being. |
I got it. Thanks! |
env
go 1.17
What happened ?
data2 has not been changed.
What is expected ?
data2 has been changed as same as data and data1.
The text was updated successfully, but these errors were encountered: