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
package main
import"github.com/tidwall/sjson"constjson=`{"object1":{"object2":[{"nested_object1":{"nested_object2":[{"nested2_object1":1},{"nested2_object1":1}]}}]}}`funcmain() {
value, _:=sjson.Set(json, "object1.object2.#.nested_object1.nested_object2.#.nested2_object1", 2)
println("updated all nested arrays objects with # identifier: ", value)
value2, _:=sjson.Set(json, "object1.object2.#.nested_object1.nested_object2.0.nested2_object1", 2)
value3, _:=sjson.Set(value2, "object1.object2.#.nested_object1.nested_object2.1.nested2_object1", 2)
println("updated nested arrays with index identifier, one by one: ", value3)
}
Output:
updated all nested arrays objects with # identifier: 2ect1":{"object2":[{"nested_object1":{"nested_object2":[{"nested2_object1":1},{"nested2_object1":1}]}}]}}
updated nested arrays with index identifier, one by one: {"object1":{"object2":[{"nested_object1":{"nested_object2":[{"nested2_object1":2},{"nested2_object1":2}]}}]}}
As we can see, when I try to update the same property of nested array's objects, it is not able to do it
But when I do it one by one, by identifying the index properly, it works
Anything I'm doing wrong ?
The text was updated successfully, but these errors were encountered:
Hello,
Here is a sample program illustrating the issue:
Output:
As we can see, when I try to update the same property of nested array's objects, it is not able to do it
But when I do it one by one, by identifying the index properly, it works
Anything I'm doing wrong ?
The text was updated successfully, but these errors were encountered: