哔哔one
这是您的原始 JSON 输入:content := `{"ShaId": "adf56a4d", "Regions": [{"Name": "us-east-1a"}]}`它不是数组,将其更改为:content := `[{"ShaId": "adf56a4d", "Regions": [{"Name": "us-east-1a"}]}]`有了这个,结果:Results: []main.ShaInfo{main.ShaInfo{ShaId:"adf56a4d", Regions:main.Region{struct { Name string }{Name:"us-east-1a"}}}}笔记:如果您输入的不是数组,则不要尝试从中解析数组(切片),只需解析一个ShaInfo. 如果您不/不能修改输入,这也适用:var data ShaInfocontent := `{"ShaId": "adf56a4d", "Regions": [{"Name": "us-east-1a"}]}`json.Unmarshal([]byte(content), &data)输出:Results: main.ShaInfo{ShaId:"adf56a4d", Regions:main.Region{struct { Name string }{Name:"us-east-1a"}}}