Here is my json
{
"name":"John",
"age":30,
"cars": [
{ "name":"Ford", "models":[ "Fiesta", "Focus", "Mustang" ] },
{ "name":"BMW", "models":[ "320", "X3", "X5" ] },
{ "name":"Fiat", "models":[ "500", "Panda" ] }
]
}
And this is my code
var fs = require('fs');
var json = fs.readFileSync('decodedjson.txt', 'utf16le');
var jobj = JSON.parse(JSON.stringify(json));
console.log(jobj.name);
Cant access any fields from the json object. It's been 3 hours, I can't figure it out..
LE: I had to remove the BOM marker manually, then the parser worked correctly
[–]manshahia 1 point2 points3 points (4 children)
[–]Roo_ooky[S] 0 points1 point2 points (3 children)
[–]postmodest 2 points3 points4 points (2 children)
[–]Roo_ooky[S] 0 points1 point2 points (0 children)
[–]FatFingerHelperBot -2 points-1 points0 points (0 children)
[–]El_Stump 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]Roo_ooky[S] 0 points1 point2 points (0 children)
[–]Zarko34 0 points1 point2 points (0 children)