func main() {
j := gjson.New(nil)
for i := 0; i < 5; i++ {
j.Set(fmt.Sprintf(`%d.id`, i), i)
j.Set(fmt.Sprintf(`%d.name`, i), fmt.Sprintf(`student-%d`, i))
}
fmt.Println(j.MustToJsonString())
// Output:
// [{"id":0,"name":"student-0"},{"id":1,"name":"student-1"},{"id":2,"name":"student-2"},{"id":3,"name":"student-3"},{"id":4,"name":"student-4"}]
}