Currently diving into the world of AngularJS and conducting some tests, I've encountered a rather perplexing issue: I'm attempting to retrieve data from a JSON file, convert it into an object, and display its properties on the screen. From my understanding, $http is supposed to automatically parse JSON text, so I crafted the following code:
$http.get("/people").success(
function(data, status, headers, config) {
$scope.data = data.people;
}
);
This is the contents of my JSON file:
{ "people": [
{
"id": "0",
"name": "Cave Jhonson",
"company": "Aperture Science"
},
{
"id": "1",
"name": "Gustavo Fring",
"company": "Los Pollos Hermanos"
}
]
}
The file resides in my project folder, and I am using a Python server. To showcase the information, I have created a simple HTML snippet:
<p>{{data.people[0].name}}</p>
Upon launching the page in Firefox, however, the information fails to appear and I am confronted with this error message: "Error: JSON.parse: expected property name or '}'". My JSON is valid, leaving me baffled as to why $http is not performing the necessary parsing.