sjson
sjson copied to clipboard
Appending an array entry retrieved from gjson selector result => double arrification
dest := "[]"
r := gjson.Get(source, "[a, b]"
dest = sjson.Set(dest, ".-1", r.String())
r is something like ["a_value","b_value"] and gets inserted into dest as [[["a_value","b_value"]]]
How can I insert the already arryfied JSON as-is into dest and avoid that it gets arryfied once again?
Perhaps the SetRaw function is what you are looking for.
r := gjson.Parse(`["a_value","b_value"]`)
dest := "[]"
dest, _ = sjson.SetRaw(dest, "-1", r.String())
println(dest)
[["a_value","b_value"]]