Reputation: 5658
My JSON:
[
{"animal":"dog", "isCute":"true"},
{"animal":"worm", "isCute":"false"},
]
When I call $http.get() with the URL that serves this JSON, I get the following error. Is my JSON formatted incorrectly, or am I doing something else wrong?
SyntaxError: Unexpected token ]
at Object.parse (native)
at Ib (angular.min.js:13:504)
at e.defaults.transformResponse (angular.min.js:59:501)
at angular.min.js:59:262
at Array.forEach (native)
at q (angular.min.js:7:264)
at ac (angular.min.js:59:244)
at c (angular.min.js:60:458)
at r (angular.min.js:96:280)
at angular.min.js:97:417
Upvotes: 3
Views: 425
Reputation: 39522
You have a comma after your second object, remove that:
[
{"animal":"dog", "isCute":"true"},
{"animal":"worm", "isCute":"false"}
]
I've found JSONLint to help when diagnosing JSON problems like yours.
Upvotes: 4