Bad control character in string literal in JSON at position 197 error is what i get when I try to parse this json string:
var obj = JSON.parse('[{"name":"Charles freed from Nepal jail","content":"A French serial killer known as The Serpent, convicted of several tourist murders in Asia in the 1970s, has been released from a Nepalese prison.rnrnCharles Sobhraj, 78, was freed after a court ruled in favour of his age and good behaviour.rnrnHe spent 19 years in jail in Nepal for killing two North Americans in 1975.","id":"1"}]');
And i really don’t know what am I doing wrong.
I know for sure, that if I try to parse the json without a linebreak it works just fine, but when I try to have a content with a line break it just doen’t work. I am not sure what the problem is here.
2
Answers
The issue is you have to escape your new line character with another slash,
eg rn
You just have to write double
\