'How can I remove \ (backslash)? [duplicate]

I use gin web framework and this is data in redis

[
  {
    "Score": 12,
    "Member": "{"empname":"DDDDDDDD","empid":20}"
  },
  {
    "Score": 5,
    "Member": "{"empname":"Dixya Lhyaho","empid":10}"
  }
]

after fetch from redis , why return like this

[
  {
    "Score": 12,
    "Member": "{\"empname\":\"DDDDDDDD\",\"empid\":20}"
  },
  {
    "Score": 5,
    "Member": "{\"empname\":\"Dixya Lhyaho\",\"empid\":10}"
  }
]

How to remove backslash in json (member only) ?


https://go.dev/play/p/QtaapMgfjtn

done.



Solution 1:[1]

Strongly recommend you to use json.NewDecoder() and then convert your struct by using the Decode() method. This is much more faster than Unmarshal. You can check on detail the json documentation that Garr left you as a comment. Anyway, how are you converting this struct to json? So we can help you better

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Lucio De Simone