I used to write python, just started to contact golang
my json for example,children unknow numbers,may be three ,may be ten。
[{
"id": 1,
"name": "aaa",
"children": [{
"id": 2,
"name": "bbb",
"children": [{
"id": 3,
"name": "ccc",
"children": [{
"id": 4,
"name": "ddd",
"children": []
}]
}]
}]
}]
i write struct
type AutoGenerated []struct {
ID int `json:"id"`
Name string `json:"name"`
Children []struct {
ID int `json:"id"`
Name string `json:"name"`
Children []struct {
ID int `json:"id"`
Name string `json:"name"`
Children []struct {
ID int `json:"id"`
Name string `json:"name"`
Children []interface{} `json:"children"`
} `json:"children"`
} `json:"children"`
} `json:"children"`
}
but i think this too stupid。 how to optimize?