Closed clarkmcc closed 3 years ago
The only way I can think of is by first assigning an object using the SetRaw
function.
str, _ := sjson.SetRaw("{}", "foo", "{}")
fmt.Println(str) // {"foo":{}}
str, _ = sjson.Set(str, "foo.1", 10)
fmt.Println(str) // {"foo":{"1":10}}
In gjson, I can get the value of a numbered key, for example
However, in sjson, because of the way array values are set, I can't set the same key. Is there a way to get around this?
Here is the reproduction script