Golang json.Unmarshal throws error for newline character. Go Playground
How to unmarshal data if string contains newline?
Golang json.Unmarshal throws error for newline character. Go Playground
How to unmarshal data if string contains newline?
Simply escaping the newline character should do the trick:
var val []byte = []byte(`"{\"channel\":\"buupr\
iya\",\"name\":\"john\", \"msg\":\"doe\"}"`)
The output for the above:
{"channel":"buupr
iya","name":"john", "msg":"doe"}
Since you're attempting to pass a raw string literal here, you will need to be able to represent the JSON in string form, which requires you to escape the newline character.