Is there a possible way to parse a string with breaklines to an object using JSON.parse?
const text = '{ "name": "Anne", "desc": "Hi,\nThis is me" }';
const obj = JSON.parse(text);
console.log(obj);
Is there a possible way to parse a string with breaklines to an object using JSON.parse?
const text = '{ "name": "Anne", "desc": "Hi,\nThis is me" }';
const obj = JSON.parse(text);
console.log(obj);
There are two things here:
"Hi,\\nThis is me"
,
, instead of a :
: const text = '{ "name": "Anne", "desc": "Hi,\\nThis is me" }';
const obj = JSON.parse(text);
console.log(obj);
output:
{
name: "Anne" ,
desc: "Hi, This is me"
}