0

I am trying to reading a txt file that has the following data:

number code date        type    name
1       232 2018-09-11  normal  luis
2       44  2018-09-11  normal  lucas
3       42  2018-09-11  normal  jean
4       5   2018-09-11  normal  nil

But I need to convert that to json object like this:

[
 {  "number": 1,
    "code": 232,
    "date": "2018-09-11",
    "type": "normal",
    "name": "luis"
 },
 {  "number": 2,
    "code": 44,
    "date": "2018-09-11",
    "type": "normal",
    "name": "lucas"
 }
]

I was trying something like:

var all_data_txt = JSON.parse(read_txt_content);

But I don't know what to do, tahnks in advance

georgeawg
  • 48,608
  • 13
  • 72
  • 95
Israel
  • 121
  • 10

0 Answers0