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
I've a JSON {"name":{"first":"kishore"}} , when I try the Set Operation by loading "name"."first" It doesn't reflect the Modified Value.
However the Set Operation by loading "name" Container works.
package main
import (
"fmt"
"github.com/Jeffail/gabs/v2"
)
func main() {
jsonParsed, err := gabs.ParseJSON([]byte(`{"name":{"first":"kishore"}}`))
if err != nil {
panic(err)
}
container := jsonParsed.S("name", "first")
container.Set("Modified")
fmt.Printf("Container Value : %s\n",container.Data())
fmt.Printf("Modified Using First Container JSON : %s\n", jsonParsed.String())
container = jsonParsed.S("name")
container.Set("Modified1", "first")
fmt.Printf("Modified Using Name Container JSON : %s\n", jsonParsed.String())
}
Actual Output:
Container Value : Modified
Modified Using First Container JSON : {"name":{"first":"kishore"}}
Modified Using Name Container JSON : {"name":{"first":"Modified1"}}
Expected Output:
Container Value : Modified
Modified Using First Container JSON : {"name":{"first":"Modified"}}
Modified Using Name Container JSON : {"name":{"first":"Modified1"}}
Hey @bandikishores, the Set function should always have at least one path parameter, otherwise you are setting a reference type that gets immediately dropped. There's maybe a case for panicking here in order to prevent the silent failure.
I've a JSON
{"name":{"first":"kishore"}}
, when I try theSet
Operation by loading"name"."first"
It doesn't reflect the Modified Value.However the
Set
Operation by loading"name"
Container works.Actual Output:
Container Value : Modified
Modified Using First Container JSON : {"name":{"first":"kishore"}}
Modified Using Name Container JSON : {"name":{"first":"Modified1"}}
Expected Output:
Container Value : Modified
Modified Using First Container JSON : {"name":{"first":"Modified"}}
Modified Using Name Container JSON : {"name":{"first":"Modified1"}}
Playground : https://play.golang.org/p/hX1-ed4nxEi
The text was updated successfully, but these errors were encountered: