I have a file with data written by a lua script that I am trying to convert into JSON. The data is formatted as follows:
{"ID" : 51, "name" : "John", "relationship" : "Friend", "Lat" : 56.166609, "Long" : 27.157364}
{"ID" : 52, "name" : "Sally", "relationship" : "Friend", "Lat" : 55.895501, "Long" : 26.753631}
I need to convert it to:
[
{
"time" : 0.00,
"ID" : 51,
"name" : "John",
"relationship" : "Friend",
"Lat" : 56.166609,
"Long" : 27.157364
},
{
"time" : 0.00,
"ID" : 52,
"name" : "Sally",
"relationship" : "Friend",
"Lat" : 55.895501,
"Long" : 26.753631
}
]
Currently I am trying the code below, which works with a single line of data but not with multiple lines of data. I haven't been able to figure out what additional steps are needed for multilpe lines (the actual data file will be hundreds of lines) :
const response2 = await fetch('Export.log');
var data2 = await response2.text();
var formatted = JSON.parse(data2);
console.log(formatted);