let x = "[{\"{\\\"value\\\":\\\" 2333333333\\\",\\\"phone_number_type\\\":null}\"}]"
let parseX=JSON.parse(x)
console.log(x)
//I want the output to [{"value":"2333333333","phone_number_type":null}]
CodePudding user response:
I would expect JSON.parse to throw an error because the JSON string in x is invalid JSON. See JSON.org for more details. The [{{...}}] is invalid it should be [{...}]
CodePudding user response:
//I have resolved this problem so what we can do is :
x='[{"\\"value\\":\\"[email protected]\\",\\"email_address_type\\":null}"}]';
x=x.replaceAll('\\', '');
x=x.replace('{"',"")
x=x.replace('"}',"")
console.log(JSON.parse(str));
//In this way you can parse the value to
[{"value":"2333333333","phone_number_type":null}]