You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Create new obj
jsonObj := gabs.New()
// Add array of size 0
jsonObj.ArrayOfSize(0, "array")
// Create an element ...
e := gabs.New()
// ... with a field a and value 11
e.Set(11, "a")
// Add element to array
jsonObj.ArrayAppend(e, "array")
// Now access element
eInArray, _ := jsonObj.ArrayElement(0, "array")
// Print the element in the array
fmt.Println("e before", eInArray.String())
// Change the value to 22
eInArray.Set(22, "a")
// Print the element in the array again
fmt.Println("e after", eInArray.String()) // ERROR: why is a not 22 now?
// Print the whole jsonObc
fmt.Println(jsonObj.String()) // ERROR: why is a not 22 now?
Output is this
e before {"a":11}
e after {"a":11}
{"array":[{"a":11}]}
Edit:
jsonObj.SetP(33, "array.0.a") also does not change the value from 11 to 33
The text was updated successfully, but these errors were encountered:
What goes wrong here?
Output is this
Edit:
jsonObj.SetP(33, "array.0.a")
also does not change the value from 11 to 33The text was updated successfully, but these errors were encountered: