how to add item in slice?
cwww3 opened this issue · 0 comments
cwww3 commented
// Is this a right way?
func main() {
var data = []byte(`[1,2,3]`)
cnt := 2
data,_ = jsonparser.Set(data,[]byte("3,4"),fmt.Sprintf("[%v]", cnt))
fmt.Println(string(data))
// Output: [1,2,3,4]
tmp := []int{}
_ = json.Unmarshal(data,&tmp)
fmt.Println(len(tmp))
// Output: 4
}