I use gin web framework and this is data from redis
languages := []*redis.Z{
{score: 40.0, member: {"id":"1","title":"C "}},
{score: 95.0, member: {"id":"2","title":"JS"}},
}
return (json)
[
{
"score": 40,
"member": "{\"id\":\"1\",\"title\":\"C \"}"
},
{
"score": 95,
"member": "{\"id\":\"2\",\"title\":\"JS\"}"
}
]
How to remove backslash in json (member only) ?
CodePudding user response:
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
CodePudding user response:
You can use the ReplaceAll method from the strings module.