I have a JSON array with objects in Redis that I want to loop through it, but when I fetch the data, the type is interface{}, so I cannot range over type interface{}
array := redis.Do(ctx, "JSON.GET", "key")
arrayResult, e := array.Result()
if e != nil {
log.Printf("could not get json with command %s", e)
}
for _, i := range arrayResult {
fmt.Printf(i)
}
2
Answers
Thank you guys, I found a solution. so at first I needed to convert the arrayResult to byte. Then I unmarshal it into a strcut, so now I am able to range over it.
I believe you should be able to do