Been dabbing in Redis with Go 1.19 as the backend lang and have been stuck trying to convert the JSONGet return value (res interface{}) to a map. I'm using "github.com/nitishm/go-rejson/v4" as the Redis JSON library.
Asked
Active
Viewed 176 times
1 Answers
0
This worked for me. Let me know what you all think!
func RawRedisJSONToMap(redisObj interface{}) map[string]interface{} {
ba := make([]byte, 0, len(redisObj.([]uint8)))
for _, b := range redisObj.([]uint8) {
ba = append(ba, b)
}
var m map[string]interface{}
json.Unmarshal(ba, &m)
return m
}

RamelHenderson
- 2,151
- 2
- 13
- 12