How to convert the data in this format into an array by data.data

Mar.23,2021

var dataArr = JSON.parse(data.data);

method for converting js class arrays to arrays


you can replace rPlan with empty first, and then convert it, otherwise the conversion will report an error, as follows:

var k = data.data
JSON.parse(k.replace(/r\n/g, ''))

of course, as a front-end developer, I just want to say who wrote the back-end, which is not friendly at all! The data provided by the back end should not contain such disorganized characters.
example is as follows:

var k = '[r\n {\r\n \"sub\":\"baidu\"} \r\n]';
JSON.parse(k.replace(/r\n/g, ''))
//[{sub: "baidu"}]
Menu