I am trying to get a JSON object from an external file, but I always get the error: malformed , that points to the first { of my JSON file. I tested my JSON file on this website: http://jsonlint.com/ and it is valid.
This is my JSON code:
{
"employees": [{
"firstName": "John",
"lastName": "Doe"
}, {
"firstName": "Anna",
"lastName": "Smith"
}, {
"firstName": "Peter",
"lastName": "Jones"
}
]
}
And this is my script:
$.getJSON("employe.json", function (data) {
document.write(data.employees[0].firstName);
});
What am I doing wrong?