如何在[] string(字符串数组的每个索引中的单个JSON字符串)中存储JSON数组(以字符串格式)?
package main
import (
"encoding/json"
"fmt"
)
type StructData struct {
Data []string `json:"data"`
}
func main() {
empArray := "[{\"abc\":\"abc\"},{\"def\":\"def\"}]"
var results []map[string]interface{}
json.Unmarshal([]byte(empArray),&results)
pr := &StructData{results}
prAsBytes,err := json.Marshal(pr)
if err != nil {
fmt.Println("error :",err)
}
}
这是我遇到的错误
cannot use results (type []map[string]interface {}) as type []string in field value
还有其他方法可以将每个json字符串数据存储在字符串数组的每个索引中吗?