I have the following code that splits a string on the newline character and then calls JSON.parse on each line.
var lines = [];
var ks = data.split("\n");
_(ks).each(function(line){
lines.push(JSON.parse(line));
}, this);
return lines;
The problem is after the split each line is like this
"{"id":"123","attr1":"abc"}"
However in order for JSON.parse to work my string needs to be surrounded my single quotes like
'{"id":"123","attr1":"abc"}'
Is there a way to perform this conversion on each line?
'and'then JSON.parse would fail because'isn't a string delimiter in JSON.