Quantcast
Viewing all articles
Browse latest Browse all 2

Cannot convert string map to json

I'd like to make a json out of a hash received from redis using redigo:

func showHashtags(c *gin.Context) {
    hashMap, err := redis.StringMap(conn.Do("HGETALL", MyDict))
    if err != nil {
        fmt.Println(err)
    }    
    fmt.Println(hashMap) //works fine and shows the map 

    m := make(map[string]string)
    for k, v := range hashMap {
        m[k] = v
    }

    jmap, _ := json.Marshal(m)
    c.JSON(200, jmap)
}

However the result in browser is gibberish like:

"eyIgIjoiMiIsIjExX9iq24zYsSAiOiIxIiwiQWxsNFJhbWluICI6IjEiLCJCSUhFICI6IjMiLCJCVFNBUk1ZICI6IjIiLCJDTUJZTiAiOiIxI....

What is wrong here? How can I fix it?


Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>