I am new to javaScript, suppose I have a text file (test.txt) contains hundreds of lines of code and have the following format:
4 6
5 7
4 7
2 6
...
The first num in each line is source and second num is target. Right now I want to parse into the javaScript objects like this:
var links = [
{source: '4', target: '6'},
{source: '5', target: '7'},
{source: '4', target: '7'},
{source: '2', target: '6'}];
How can I do that?