github.com/gogf/gf@v1.16.9/.example/container/gset/json_marshal.go (about)

     1  package main
     2  
     3  import (
     4  	"encoding/json"
     5  	"fmt"
     6  	"github.com/gogf/gf/container/gset"
     7  )
     8  
     9  func main() {
    10  	type Student struct {
    11  		Id     int
    12  		Name   string
    13  		Scores *gset.IntSet
    14  	}
    15  	s := Student{
    16  		Id:     1,
    17  		Name:   "john",
    18  		Scores: gset.NewIntSetFrom([]int{100, 99, 98}),
    19  	}
    20  	b, _ := json.Marshal(s)
    21  	fmt.Println(string(b))
    22  }