I am reading all record set from aerospike set as below:
stmt := as.NewStatement(namespace, set)
recordSet, err := db.AerospikeClient.Query(nil,stmt)
now I want to map the result records to the struct of the set. How can I do that?
I tried mapping record.Bins to struct but it didn't worked. The result should be array of below struct:
type MyStruct struct {
name string `as:"userId" json:"userId"`
UserList []UserList `as:"userList" json:"userList"`
CreatedAt int64 `as:"createdAt" json:"createdAt"`
UpdatedAt int64 `as:"updatedAt" json:"updatedAt"`
}
Here is the code that I tried:
for rec := range recordSet.Records {
var myStruct MyStruct
jsonString, err := json.Marshal(rec.Bins)
if err != nil {
utils.LogErr("","", "Error occurred while marshling all the records from old set to my struct", err)
return nil, err
}
err = json.Unmarshal(jsonString,&myStruct)
}
It is giving below error:
"error":"json: unsupported type: map[interface {}]interface {}"