I am writing a test where I want to compare the result of json.Marshal
with a static json string:
var json = []byte(`{
"foo": "bar"
}`)
As the result of json.Marshal
does not have any
, \t
and spaces I thought I could easily do:
bytes.Trim(json, "
\t")
to remove all of these characters.
However unfortunately this does not work. I could write a custom trim function and use bytes.TrimFunc
but this seems to complicated to me.
What else could I do to have a json string "compressed" with as less code as possible?
Best, Bo