Within a file, the data (list) is structured as follows:
[5,[5,[5,100,-200],200,-400],300,-500]
Upon reading this file in an angular application, the contents are converted into a string object like so:
"[5,[5,[5,100,-200],200,-400],300,-500]"
Is there a way to revert this string back to its original list format?
While there is one method to tackle a different problem, where the file contains data:
200
300
400
500
The string can be split using:
var newData = fileContent.split('\n');
desiredList = []
for(var z=0;z<newData.length;z++){
desiredList.push(parseInt(newData[z]))
}
This provides the desired list structure. However, for the initial question posed, is there an alternative solution?