切片数据转换为json tree树结构"/>
golang切片数据转换为json tree树结构
父子切片数据转换为json树结构
type Node struct {Id int `json:"id"`ParentId int `json:"parentId"`Name string `json:"name"`Children []*Node `json:"children,omitempty"`
}func generateTree(rows []*Node) []*Node {idMap := make(map[int]*Node, len(rows))topNode := &Node{}idMap[topNode
更多推荐
golang切片数据转换为json tree树结构
发布评论