I am reading a txt file which has JSON objects where the objects are not separated by commas. I would like to add commas between the json objects and place them all into a JSON list or Array.
I have tried JSON.loads but I am getting the JSON Decode error. So I realized i am supposed to put commas in between the different objects present in the .txt file
Below is the example of the file content in .txt
{
"@mdate": "2011-01-11",
"@key": "journals/acta/Saxena96",
"author": {
"ftail": "\n",
"ftext": "Sanjeev Saxena"
},
"title": {
"ftail": "\n",
"ftext": "Parallel Integer Sorting and Simulation Amongst CRCW Models."
},
"pages": {
"ftail": "\n",
"ftext": "607-619"
},
"year": {
"ftail": "\n",
"ftext": "1996"
},
"volume": {
"ftail": "\n",
"ftext": "33"
},
"journal": {
"ftail": "\n",
"ftext": "Acta Inf."
},
"number": {
"ftail": "\n",
"ftext": "7"
},
"url": {
"ftail": "\n",
"ftext": "db/journals/acta/acta33.htmlfSaxena96"
},
"ee": {
"ftail": "\n",
"ftext": "http://dx.doi.org/10.1007/BF03036466"
},
"ftail": "\n",
"ftext": "\n"
}{
"@mdate": "2011-01-11",
"@key": "journals/acta/Simon83",
"author": {
"ftail": "\n",
"ftext": "Hans-Ulrich Simon"
},
"title": {
"ftail": "\n",
"ftext": "Pattern Matching in Trees and Nets."
},
"pages": {
"ftail": "\n",
"ftext": "227-248"
},
"year": {
"ftail": "\n",
"ftext": "1983"
},
"volume": {
"ftail": "\n",
"ftext": "20"
},
"journal": {
"ftail": "\n",
"ftext": "Acta Inf."
},
"url": {
"ftail": "\n",
"ftext": "db/journals/acta/acta20.htmlfSimon83"
},
"ee": {
"ftail": "\n",
"ftext": "http://dx.doi.org/10.1007/BF01257084"
},
"ftail": "\n",
"ftext": "\n"
}
''''''''''''''''''''''''''''''''''''
Expected Result:
''''''''''''''''''''''''''''''''''''
[
{
"@mdate": "2011-01-11",
"@key": "journals/acta/Saxena96",
"author": {
"ftail": "\n",
"ftext": "Sanjeev Saxena"
},
"title": {
"ftail": "\n",
"ftext": "Parallel Integer Sorting and Simulation Amongst CRCW Models."
},
"pages": {
"ftail": "\n",
"ftext": "607-619"
},
"year": {
"ftail": "\n",
"ftext": "1996"
},
"volume": {
"ftail": "\n",
"ftext": "33"
},
"journal": {
"ftail": "\n",
"ftext": "Acta Inf."
},
"number": {
"ftail": "\n",
"ftext": "7"
},
"url": {
"ftail": "\n",
"ftext": "db/journals/acta/acta33.htmlfSaxena96"
},
"ee": {
"ftail": "\n",
"ftext": "http://dx.doi.org/10.1007/BF03036466"
},
"ftail": "\n",
"ftext": "\n"
},
{
"@mdate": "2011-01-11",
"@key": "journals/acta/Simon83",
"author": {
"ftail": "\n",
"ftext": "Hans-Ulrich Simon"
},
"title": {
"ftail": "\n",
"ftext": "Pattern Matching in Trees and Nets."
},
"pages": {
"ftail": "\n",
"ftext": "227-248"
},
"year": {
"ftail": "\n",
"ftext": "1983"
},
"volume": {
"ftail": "\n",
"ftext": "20"
},
"journal": {
"ftail": "\n",
"ftext": "Acta Inf."
},
"url": {
"ftail": "\n",
"ftext": "db/journals/acta/acta20.htmlfSimon83"
},
"ee": {
"ftail": "\n",
"ftext": "http://dx.doi.org/10.1007/BF01257084"
},
"ftail": "\n",
"ftext": "\n"
}
]
''''''''''''''''''''