呼唤远方
下面的代码应该可以满足您的需求:package mainimport ( "encoding/json" "fmt")var input = `{ "aaaa": 142, "bbbb": "", "cccc": { "c1": 121, "needed": [ { "_c21": 22.25972, "_c22": { "needed1": "123", "needed2": "test" } }, { "_c21": 22.25972, "_c22": { "needed1": "123", "needed2": "test" } }, { "_c21": 22.25972, "_c22": { "needed1": "123", "needed2": "test" } } ] }}`type Json struct { Cccc struct { NeededList []struct { C22 needed `json:"_c22"` } `json:"needed"` }`json:"cccc"`}type needed struct { Needed1 string `json:"needed1"` Needed2 string `json:"needed2"`}func main() { j := &Json{} json.Unmarshal([]byte(input), j) result := make([]needed, 0) for _, n := range j.Cccc.NeededList { result = append(result, n.C22) } out, _ := json.Marshal(result) fmt.Println(string(out))}