The following is the JSON I'm trying to parse:
{[{"name":"Technology"},{"name":"Engineering"},{"name":"Business"}]}
I'm getting the error below:
Unexpected token [ in JSON at position 1
at JSON.parse (<anonymous>)
at fromJson
I'm getting the data from a service and saving it into the controller scope using the following:
vm = this;
vm.sectorList = response.data;
And my HTML:
<div ng-repeat="sector in ctrl.sectorList">
{{sector.name}}
</div>
The JSON is invalid, hence the error you're getting. You're missing a key to go with the JSON array value. This for instance (key "anything" added) will work:
{"anything": [{"name":"Technology"},{"name":"Engineering"},{"name":"Business"}]}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With