Why can't this scenario assign a value to a list?
jianghaodong-icel opened this issue · comments
type StudentInfo struct {
StudentId string `json:"student_id"`
Class []string `json:"class"`
}
type Item struct {
StudentInfo []*StudentInfo `json:"student_info"`
}
func main() {
item := &Item{
[]*StudentInfo{
{
StudentId: "1",
Class: []string{"class1"},
},
},
}
itemBytes, _ := json.Marshal(item)
ret, _ := sjson.Set(string(itemBytes), `student_info.#(student_id=="1").class.-1`, "class2")
fmt.Println(ret)
}
my desired result is {"student_info":[{"student_id":"1","class":["class1","class2"]}]}
,but the actual result is {"student_info":[{"student_id":"1","class":["class1"]}]}
I'm dealing with the same problem. Did you manage to solve it? @jianghaodong-icel