zhanwei...
package main import ( "encoding/json" "fmt" "github.com/tidwall/gjson" "io/ioutil" "log" "net/http" ) func httpGet() string { resp, err := http.Get("https://coopera3f7e.com/xxxxx") if err != nil { // handle error } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { // handle error } //fmt.Println(string(body)) return string(body) } type Person struct { Name string `json:"name"` //Hobby string `json:"hobby"` } type TT struct { T1 []Person `json:"test"` } type FileDes struct { FileId string `json:"file_id"` //Hobby string `json:"hobby"` Pic_path string `json:"thumbnail_full_path"` } type TTT struct { T2 []FileDes `json:"5f4f334147cf2103f8c58814"` } func main() { str_json:=httpGet() //log.Println(str_json) value2 := gjson.Get(str_json,"data.5f4f334147cf2103f8c58814") //log.Println("{"5f4f334147cf2103f8c58814":"+value2.Str+"}") //重要,构造成json key:value的格式,为解析做准备,value2.str 最开始==> [{"a":"b"},{"a","b"},{"a","c"}] mdfile := "{"5f4f334147cf2103f8c58814":"+value2.Str+"}" mdfl :=[]byte(mdfile) //str_tmp:=`{"test":[{"Name":"zhangsan","Hobby":"女"},{"Name":"zhangsan","Hobby":"女"},{"Name":"zhangsan","Hobby":"女"}]}` //log.Println(str_tmp) b := []byte(`{"test":[{"Name":"zhangsan","Hobby":"女"},{"Name":"zhangsan","Hobby":"女"},{"Name":"zhangsan","Hobby":"女"}]}`) var p TT err := json.Unmarshal(b, &p) if err != nil { fmt.Println("json err:", err) } log.Println(p) var pp TTT err = json.Unmarshal(mdfl, &pp) if err != nil { fmt.Println("json err:", err) } log.Println(pp) }